Commit 7e0b67b7 authored by Michael Kozono's avatar Michael Kozono

Merge branch '299265-rearrange-stage-event-methods' into 'master'

Rearrange VSA stage event methods

See merge request gitlab-org/gitlab!60012
parents 33b50971 5c1b1e75
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection def column_list
issue_table[:closed_at] [issue_table[:closed_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection def column_list
issue_metrics_table[:first_added_to_board_at] [issue_metrics_table[:first_added_to_board_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection def column_list
issue_metrics_table[:first_associated_with_milestone_at] [issue_metrics_table[:first_associated_with_milestone_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection def column_list
issue_table[:last_edited_at] [issue_table[:last_edited_at]]
end end
end end
end end
......
...@@ -20,13 +20,8 @@ module Gitlab ...@@ -20,13 +20,8 @@ module Gitlab
true true
end end
def timestamp_projection
Arel.sql("#{join_expression_name}.created_at")
end
override :column_list
def column_list def column_list
[timestamp_projection] [Arel.sql("#{join_expression_name}.created_at")]
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_metrics_table[:latest_closed_at] [mr_metrics_table[:latest_closed_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_metrics_table[:first_commit_at] [mr_metrics_table[:first_commit_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_table[:last_edited_at] [mr_table[:last_edited_at]]
end end
end end
end end
......
...@@ -17,11 +17,6 @@ module Gitlab ...@@ -17,11 +17,6 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection
Arel::Nodes::NamedFunction.new('COALESCE', column_list)
end
override :column_list
def column_list def column_list
[ [
issue_metrics_table[:first_mentioned_in_commit_at], issue_metrics_table[:first_mentioned_in_commit_at],
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection def column_list
issue_table[:created_at] [issue_table[:created_at]]
end end
end end
end end
......
...@@ -17,13 +17,8 @@ module Gitlab ...@@ -17,13 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection
mr_metrics_table[:first_deployed_to_production_at]
end
override :column_list
def column_list def column_list
[timestamp_projection] [mr_metrics_table[:first_deployed_to_production_at]]
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
Issue Issue
end end
def timestamp_projection def column_list
issue_metrics_table[:first_mentioned_in_commit_at] [issue_metrics_table[:first_mentioned_in_commit_at]]
end end
end end
end end
......
...@@ -17,11 +17,6 @@ module Gitlab ...@@ -17,11 +17,6 @@ module Gitlab
Issue Issue
end end
def timestamp_projection
Arel::Nodes::NamedFunction.new('COALESCE', column_list)
end
override :column_list
def column_list def column_list
[ [
issue_metrics_table[:first_associated_with_milestone_at], issue_metrics_table[:first_associated_with_milestone_at],
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_table[:created_at] [mr_table[:created_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_metrics_table[:first_deployed_to_production_at] [mr_metrics_table[:first_deployed_to_production_at]]
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_metrics_table[:latest_build_finished_at] [mr_metrics_table[:latest_build_finished_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_metrics_table[:latest_build_started_at] [mr_metrics_table[:latest_build_started_at]]
end end
end end
end end
......
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
MergeRequest MergeRequest
end end
def timestamp_projection def column_list
mr_metrics_table[:merged_at] [mr_metrics_table[:merged_at]]
end end
end end
end end
......
...@@ -11,7 +11,6 @@ module Gitlab ...@@ -11,7 +11,6 @@ module Gitlab
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
override :column_list
def column_list def column_list
[timestamp_projection] [timestamp_projection]
end end
......
...@@ -17,11 +17,6 @@ module Gitlab ...@@ -17,11 +17,6 @@ module Gitlab
Issue Issue
end end
def timestamp_projection
Arel::Nodes::NamedFunction.new('COALESCE', column_list)
end
override :column_list
def column_list def column_list
[ [
issue_metrics_table[:first_associated_with_milestone_at], issue_metrics_table[:first_associated_with_milestone_at],
......
...@@ -34,14 +34,16 @@ module Gitlab ...@@ -34,14 +34,16 @@ module Gitlab
# Each StageEvent must expose a timestamp or a timestamp like expression in order to build a range query. # Each StageEvent must expose a timestamp or a timestamp like expression in order to build a range query.
# Example: get me all the Issue records between start event end end event # Example: get me all the Issue records between start event end end event
def timestamp_projection def timestamp_projection
raise NotImplementedError columns = column_list
columns.one? ? columns.first : Arel::Nodes::NamedFunction.new('COALESCE', columns)
end end
# List of columns that are referenced in the `timestamp_projection` expression # List of columns that are referenced in the `timestamp_projection` expression
# Example timestamp projection: COALESCE(issue_metrics.created_at, issue_metrics.updated_at) # Example timestamp projection: COALESCE(issue_metrics.created_at, issue_metrics.updated_at)
# Expected column list: issue_metrics.created_at, issue_metrics.updated_at # Expected column list: issue_metrics.created_at, issue_metrics.updated_at
def column_list def column_list
[] raise NotImplementedError
end end
# Optionally a StageEvent may apply additional filtering or join other tables on the base query. # Optionally a StageEvent may apply additional filtering or join other tables on the base query.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment