Merge pull request #2086 from TracksApp/fix-top-10-longest-running

Fix the top 10 longest running projects list
This commit is contained in:
Matt Rogers 2017-07-30 15:22:56 -05:00 committed by GitHub
commit 0c18ebecc5
2 changed files with 4 additions and 1 deletions

View file

@ -22,7 +22,7 @@ module Stats
def find_top10_longest_running_projects
projects = user.projects.order('created_at ASC')
projects.sort_by{ |p| p.running_time }.take(10)
projects.sort_by{ |p| p.running_time }.reverse.take(10)
end
end

View file

@ -51,6 +51,9 @@ class StatsControllerTest < ActionController::TestCase
assert_equal 4, totals.tags
assert_equal 2, totals.unique_tags
longest_running_projects = assigns['stats'].projects.runtime
assert_equal longest_running_projects, users(:admin_user).projects.order('created_at').reverse
Time.zone = users(:admin_user).prefs.time_zone # calculations are done in users timezone
assert_equal 2.weeks.ago.at_midnight, totals.first_action_at.at_midnight
end