diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-16 09:04:49 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-17 09:46:48 +0300 |
commit | 7d69ff3ddf0fb83c6a1ec02f85b01b454080b647 (patch) | |
tree | 1753906e1f888d72433d4e763e8e733d1d76c653 /app/models/cycle_analytics | |
parent | 161804bf401cead2b06a69884d4c6622acf8dec4 (diff) |
Move cycle analytics calculations to SQL.
1. Use Arel for composable queries.
2. For a project with ~10k issues, the page loads in around 600ms.
Previously, a project with ~5k issues would have a ~20s page load
time.
Diffstat (limited to 'app/models/cycle_analytics')
-rw-r--r-- | app/models/cycle_analytics/table_references.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/cycle_analytics/table_references.rb b/app/models/cycle_analytics/table_references.rb new file mode 100644 index 00000000000..f276723ee0e --- /dev/null +++ b/app/models/cycle_analytics/table_references.rb @@ -0,0 +1,25 @@ +class CycleAnalytics + module TableReferences + class << self + def issues + Issue.arel_table + end + + def issue_metrics + Issue::Metrics.arel_table + end + + def merge_requests + MergeRequest.arel_table + end + + def merge_request_metrics + MergeRequest::Metrics.arel_table + end + + def merge_requests_closing_issues + MergeRequestsClosingIssues.arel_table + end + end + end +end |