diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-20 15:06:54 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-20 16:05:25 +0530 |
commit | 8957293d9bd0d711db3af26182205c2fe4125194 (patch) | |
tree | dcdd25393e2d6248971fddbd6c9eac30fe27ff6e /app/models/cycle_analytics | |
parent | fa890604aaf15b9e4f0199e6a4cff24c29955a37 (diff) | |
download | gitlab-ce-8957293d9bd0d711db3af26182205c2fe4125194.tar.gz |
Implement review comments from @yorickpeterse
1. Change multiple updates to a single `update_all`
2. Use cascading deletes
3. Extract an average function for the database median.
4. Move database median to `lib/gitlab/database`
5. Use `delete_all` instead of `destroy_all`
6. Minor refactoring
Diffstat (limited to 'app/models/cycle_analytics')
-rw-r--r-- | app/models/cycle_analytics/queries.rb | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/app/models/cycle_analytics/queries.rb b/app/models/cycle_analytics/queries.rb deleted file mode 100644 index 7bdf1fb6290..00000000000 --- a/app/models/cycle_analytics/queries.rb +++ /dev/null @@ -1,80 +0,0 @@ -class CycleAnalytics - class Queries - def initialize(project) - @project = project - end - - def issues(options = {}) - @issues_data ||= - begin - issues_query(options).preload(:metrics).map { |issue| { issue: issue } } - end - end - - def merge_requests_closing_issues(options = {}) - @merge_requests_closing_issues_data ||= - begin - merge_requests_closing_issues = MergeRequestsClosingIssues.where(issue: issues_query(options)).preload(issue: [:metrics], merge_request: [:metrics]) - - merge_requests_closing_issues.map do |record| - { issue: record.issue, merge_request: record.merge_request } - end - end - end - - def issue_first_associated_with_milestone_at - lambda do |data_point| - issue = data_point[:issue] - issue.metrics.first_associated_with_milestone_at if issue.metrics.present? - end - end - - def issue_first_added_to_list_label_at - lambda do |data_point| - issue = data_point[:issue] - issue.metrics.first_added_to_board_at if issue.metrics.present? - end - end - - def issue_first_mentioned_in_commit_at - lambda do |data_point| - issue = data_point[:issue] - issue.metrics.first_mentioned_in_commit_at if issue.metrics.present? - end - end - - def merge_request_merged_at - lambda do |data_point| - merge_request = data_point[:merge_request] - merge_request.metrics.merged_at if merge_request.metrics.present? - end - end - - def merge_request_build_started_at - lambda do |data_point| - merge_request = data_point[:merge_request] - merge_request.metrics.latest_build_started_at if merge_request.metrics.present? - end - end - - def merge_request_build_finished_at - lambda do |data_point| - merge_request = data_point[:merge_request] - merge_request.metrics.latest_build_finished_at if merge_request.metrics.present? - end - end - - def merge_request_deployed_to_production_at - lambda do |data_point| - merge_request = data_point[:merge_request] - merge_request.metrics.first_deployed_to_production_at if merge_request.metrics.present? - end - end - - private - - def issues_query(created_after:) - @project.issues.where("created_at >= ?", created_after) - end - end -end |