Commit 932883f3cabe5db60b133eb08140de3c820ce9e0
Committed by
Heitor
1 parent
1cf91eb7
Exists in
colab
and in
4 other branches
ModuleResult ordering done through Granularity built-in comparisons
kalibro_client updated: It enables Granularity ordering Signed off by: Rafael Reggiani Manzo
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
Gemfile.lock
| @@ -149,7 +149,7 @@ GEM | @@ -149,7 +149,7 @@ GEM | ||
| 149 | jquery-ui-rails (5.0.3) | 149 | jquery-ui-rails (5.0.3) |
| 150 | railties (>= 3.2.16) | 150 | railties (>= 3.2.16) |
| 151 | json (1.8.2) | 151 | json (1.8.2) |
| 152 | - kalibro_client (0.0.3) | 152 | + kalibro_client (0.1.0) |
| 153 | activesupport (>= 2.2.1) | 153 | activesupport (>= 2.2.1) |
| 154 | faraday_middleware (~> 0.9.0) | 154 | faraday_middleware (~> 0.9.0) |
| 155 | konacha (3.3.0) | 155 | konacha (3.3.0) |
app/helpers/kalibro_modules_helper.rb
| 1 | module KalibroModulesHelper | 1 | module KalibroModulesHelper |
| 2 | def sort_by_granularity_and_name(module_results) | 2 | def sort_by_granularity_and_name(module_results) |
| 3 | - module_results.sort do |a,b| | ||
| 4 | - (a.kalibro_module.granularity == b.kalibro_module.granularity) ? a.kalibro_module.name <=> b.kalibro_module.name : -a.kalibro_module.granularity.length <=> -b.kalibro_module.granularity.length | 3 | + module_results.sort! do |a,b| |
| 4 | + if (a.kalibro_module.granularity == b.kalibro_module.granularity) | ||
| 5 | + a.kalibro_module.name <=> b.kalibro_module.name | ||
| 6 | + else | ||
| 7 | + (KalibroClient::Entities::Miscellaneous::Granularity.new(b.kalibro_module.granularity.to_sym) <=> KalibroClient::Entities::Miscellaneous::Granularity.new(a.kalibro_module.granularity.to_sym)) | ||
| 8 | + end | ||
| 5 | end | 9 | end |
| 6 | end | 10 | end |
| 7 | end | 11 | end |
| 8 | \ No newline at end of file | 12 | \ No newline at end of file |