Faster Django Pagination App - mysql

We use django-paging, which is a bit old. One of the big issues is that the app performs a count on the queryset returned by each view, which is slow and doesn't provide us any value in our case.
I see that django-pagination has more downloads/repo-watchers. I've also used the Django Digg Style paginator in the past.
Should we switch over to a new paginator app or just strip out the count MySQL query?
Thanks

Related

Ruby: Exposing MySQL query ability to users via RESTful API

There are similar posts like this on the internet, but they seem to be targeted towards lower level languages like Java. NetBeans for example seems to have this kind of functionality.
Here is what I want to do:
I have a large dataset of items. I want to create a RESTful API that would enable my users to perform complex queries to retrieve data from the MySQL database on my backend.
The API needs to be able to:
SELECT a table to retrieve values from
Be able to use common MySQL aggregate functions such as COUNT, SUM,
and AVG on the results
Create WHERE conditions
Security is not an issue as this my simply an MVP for now. On a future iteration I will take security into consideration. Are there any Ruby gems which provide a framework for constructing this kind of system?
I am open to using either Sinatra or Rails for this system.
Maybe this can help you:rails-api
Rails::API is a subset of a normal Rails application, created for
applications that don't require all functionality that a complete
Rails application provides. It is a bit more lightweight, and
consequently a bit faster than a normal Rails application. The main
example for its usage is in API applications only, where you usually
don't need the entire Rails middleware stack nor template generation.
or you can use grape gem.

No data received error in Chrome In Ruby application

I am new in Ruby. I am using Sinatra as framework. I am working on a project that involves a few mysql queries taking reasonable amount of time. Actually there is a front end where user can input the parameters and press view button in response to which the query fires and at the completion of them view is populated.
But the problem is that due to reasonable amount of time taken by the query it is showing "no data received" in chrome though the query is executing in the backend. I don't know how to fix that, I have tried many ways to optimise the query but actually the data is much so I don't think any further optimisation possible. Thanks in advance.

Testing without affected certain tables

At the moment I'm stuck with the need to debug several functions in our system to determine if they're working or not.
The situation is basicly that I'm left with someone elses CakePHP structure which makes me unable to know the code in and out. This is due to lack of time and lack of documentation.
I need to run tests on this system, however it will cause incorrect data on our reports page when I create new orders etc. This is not allowed and basicly there's a lot of models which saves data to the reports by simply creating other rows.
The easiest solution here would be to make no report rows get created if I'm logged in as a certain user. Then I'd simply just do a condition and determine if I should insert the report row in the database or not. (if ($bool_tester) return FALSE; else /* Insert data */)
This would however require to fetch the Session data within the Model, which I've read is a bad solution. I can't simply run an extra parameter in the function, since the function is called on so many places in so many files.
So my question is basicly; Should I include Session data within the Model regardless or is there any other nifty solution that makes me not insert these rows when I'm testing.
Defining a session value through the controllers isn't a smooth solution either here.
Do the testing in your development environment, not on the live site.
Do you use unit testing for the tests? CakePHP does support that. When you are, you could stub or mock the data within your setup for the test. Cake also supports that.

Doing SQL queries in Rails with Variables - Converting a PHP/Codeigniter Application

I'm converting a PHP app written in CodeIgniter to Rails.
Due to the size of the application and the inability to makes change to the schema, I'm not interested in making models for each entity.
I want to be able to do CodeIgniter style queries like this (Supply a pre-written query and associated variables):
query("SELECT * FROM posts WHERE id = ?", id)
and get a result back.
I know that it's highly suggested to use models and do it "the rails way", and I definitely plan to for my next application that I write from scratch in Rails, but for this project I want to avoid the ORM and just have the ability to do direct queries using the database connection.
What would be the best way to do this?
I hate myself for not having the willpower to not answer this question, so just quickly:
Use ActiveRecord#find_by_sql

Output ActiveRecord MySQL queries to page

New to rails so bear with me :)
How would I go about appending all of the queries executed by ActiveRecord for each page request to the bottom of the page (i.e. application layout)? Coming from CakePHP, this is a useful tool for ensuring the code I'm writing is efficient.
I know I can change the logger via ActiveRecord::Base.logger = Logger.new(STDOUT), for example, but what would I add in to my layout file to dump a list of the queries being executed? Is there a way for me to configure the ActiveRecord logger to a variable, say in my environment.rb file?
Check out the rails footnotes gem - I think it will likely do what you want here, and give you more features as well. I haven't used it as much lately, but I used it extensively in some Rails v2 apps we had, and I just added it to a Rails v3 application to make sure it still worked as expected (and found some slow queries that need correcting as well! )