jrhorn424 / recruiter

Online recruitment software for economics experiments written with rails
MIT License
1 stars 1 forks source link

Corrections on SP page #38

Closed mlfreer closed 10 years ago

mlfreer commented 10 years ago

screen shot 2014-03-30 at 5 18 32 pm

1) add total number of sp to the table 2) add error message if you want to assign more subjects than it is in DB

jrhorn424 commented 10 years ago

That's looking great. If we want to make criteria dynamic in the future, I'd have a look at ransack. It makes it trivial to create new criteria when new columns are added to the model, and also allows you to dynamically add new filters like:

 Major: Economics OR
 Major: Physical Sciences
ppodolsky commented 10 years ago

Thanks, Jeffrey, this gem can be really useful under some conditions. Unfortunately, there are some issues. 1) I wasn't be able to find functionality for creating BETWEEN where clauses in this gem. Two "less or equal" conditions are a bad trade-off, because I traced some performance troubles with the execution plan in Postgres 9.2 2) It is useless for complex queries like we have. Calculating attendance parameter requires inlined SQL, which cannot be expressed even by Rails Model.

jrhorn424 commented 10 years ago

On 31 Mar 2014, at 15:19, Pasha Podolsky wrote:

Thanks, Jeffrey, this gem can be really useful under some conditions. Unfortunately, there are some issues. 1) I wasn't be able to find functionality for creating BETWEEN where clauses in this gem. 2) It is useless for complex queries like we have. Calculating attendance parameter requires inlined SQL, which cannot be expressed even by Rails Model.

That's unfortunate. I do believe you might be able to write more complex queries if you dive into Arel. I'd recommend doing that anyway because of the work that is done in the rails framework toward increasing security. Exposing SQL in the application layer is usually a "bad idea" and when we're afforded more time, it might be a good idea to revisit it.

ppodolsky commented 10 years ago

I reviewed Arel and still couldn't find a right solution for the query that had been placed in subject_controller.rb. Sometimes relational model cannot be properly mapped onto object model without row-by-row iterating and this is the case. You should feel free to inspect this query and if you wish - provide a solution/start a branch in Arel/Ransack terms but without row-by-row iterating. We would incorporate it into the project.