Project

General

Profile

IssueQuery and Custom Query Sort Order

Added by Albert Milani about 6 years ago

Hi,

I'm working on a plugin which already takes a Custom Query as an argument to get the appropriate issues but I'd like the plugin to sort the issues according to the sort order specified by the Custom Query as well. I see that query.sort_criteria has the info I'm looking for but a few things are wrong. This is what query.sort_criteria has:

[["cf_4", "asc"], ["cf_5", "asc"], ["id", "asc"]]
and query.issues(:order => query.sort_criteria) results in a bad ORDER BY of
ORDER BY cf_4, asc, cf_5, id
it should be
ORDER BY cf_4.value asc, cf_5.value asc, issues.id asc

Is there something I'm missing that I'm supposed to be doing to sort_criteria to fix it?

This obviously works in redmine/app/controllers/issues_controller.rb but I just can't figure it out how to apply it to my situation.

More Info
  1. I'm working on this plugin, Traceability matrix and the pertinent lines are in app/controllers/mt_controller.rb (attached) around line 30, right at the top of the function, build_list_of_issues. I want to replace the sort there with the Custom Query's sort criteria by just using the order option of issues().
  2. I'm really new at Ruby, Ruby on Rails, and Redmine plugins so please don't assume anything about what I know.

Thanks,
Albert