diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-22 14:37:59 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-23 11:46:55 +0200 |
commit | 13d39971f33e4064bd5c8da1865cc874e1005e52 (patch) | |
tree | 8f4563162e928b52eb638e7d9e3e0987c53a5115 /lib/ci | |
parent | 9c7bf123564ee3c045c2aa3625f8a691f91a23aa (diff) | |
download | gitlab-ce-13d39971f33e4064bd5c8da1865cc874e1005e52.tar.gz |
Improve performance for pipeline charts
Achieved by using another table, which both has better indexes and
is smaller. Now the data provided for the user is more valueable too.
Diffstat (limited to 'lib/ci')
-rw-r--r-- | lib/ci/charts.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ci/charts.rb b/lib/ci/charts.rb index 6063d6f45e8..ca09410838d 100644 --- a/lib/ci/charts.rb +++ b/lib/ci/charts.rb @@ -3,7 +3,7 @@ module Ci module DailyInterval def grouped_count(query) query - .group("DATE(#{Ci::Build.table_name}.created_at)") + .group("DATE(#{Ci::Pipeline.table_name}.created_at)") .count(:created_at) .transform_keys { |date| date.strftime(@format) } end @@ -17,12 +17,12 @@ module Ci def grouped_count(query) if Gitlab::Database.postgresql? query - .group("to_char(#{Ci::Build.table_name}.created_at, '01 Month YYYY')") + .group("to_char(#{Ci::Pipeline.table_name}.created_at, '01 Month YYYY')") .count(:created_at) .transform_keys(&:squish) else query - .group("DATE_FORMAT(#{Ci::Build.table_name}.created_at, '01 %M %Y')") + .group("DATE_FORMAT(#{Ci::Pipeline.table_name}.created_at, '01 %M %Y')") .count(:created_at) end end @@ -46,8 +46,8 @@ module Ci end def collect - query = project.builds - .where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", @to, @from) + query = project.pipelines + .where("? > #{Ci::Pipeline.table_name}.created_at AND #{Ci::Pipeline.table_name}.created_at > ?", @to, @from) totals_count = grouped_count(query) success_count = grouped_count(query.success) |