Skip to content

Commit

Permalink
[api] Refactor StatisticsCalculations class
Browse files Browse the repository at this point in the history
* Sort results right away instead of temporarely storing it
* Shorten how we apply the limit
  • Loading branch information
bgeuken committed Oct 5, 2017
1 parent b1c1acf commit 3c2e02b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/api/lib/statistics_calculations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ def self.get_latest_updated(limit = 10, timelimit = Time.at(0), prj_filter = ".*
pluck(:name, :updated_at).
map { |name, at| [at, name, :project] }

list = packages + projects
list.sort! { |a, b| b[0] <=> a[0] }
return list if limit.nil?
list.first(limit)
list = (packages + projects).sort { |a, b| b[0] <=> a[0] }

limit ? list.first(limit) : list
end
end

0 comments on commit 3c2e02b

Please sign in to comment.