Class: ClickHouse::Models::Ci::FinishedPipelinesBase
- Inherits:
-
BaseModel
- Object
- Client::QueryLike
- BaseModel
- ClickHouse::Models::Ci::FinishedPipelinesBase
show all
- Defined in:
- lib/click_house/models/ci/finished_pipelines_base.rb
Instance Attribute Summary
Attributes inherited from BaseModel
#query_builder
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseModel
#group, #initialize, #limit, #offset, #order, #select, table_name, #where
Class Method Details
.by_status(statuses) ⇒ Object
15
16
17
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 15
def self.by_status(statuses)
new.by_status(statuses)
end
|
.for_container(container) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 23
def self.for_container(container)
if container.is_a?(Project)
new.for_project(container)
else
new.for_group(container)
end
end
|
.group_by_status ⇒ Object
19
20
21
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 19
def self.group_by_status
new.group_by_status
end
|
.time_window_valid?(from_time, to_time) ⇒ Boolean
7
8
9
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 7
def self.time_window_valid?(from_time, to_time)
raise NotImplementedError, "subclasses of #{self.class.name} must implement #{__method__}"
end
|
.validate_time_window(from_time, to_time) ⇒ Object
11
12
13
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 11
def self.validate_time_window(from_time, to_time)
raise NotImplementedError, "subclasses of #{self.class.name} must implement #{__method__}"
end
|
Instance Method Details
#by_status(statuses) ⇒ Object
64
65
66
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 64
def by_status(statuses)
where(status: statuses)
end
|
#count_pipelines_function ⇒ Object
87
88
89
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 87
def count_pipelines_function
Arel::Nodes::NamedFunction.new('countMerge', [@query_builder.table[:count_pipelines]])
end
|
#duration_quantile_function(quantile) ⇒ Object
91
92
93
94
95
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 91
def duration_quantile_function(quantile)
Arel::Nodes::NamedFunction
.new("quantileMerge(#{quantile / 100.0})", [@query_builder.table[:duration_quantile]])
.as("p#{quantile}")
end
|
#for_group(group) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 43
def for_group(group)
traversal_path = group.traversal_path
condition =
Arel::Nodes::NamedFunction.new('startsWith', [Arel.sql('path'), Arel::Nodes.build_quoted(traversal_path)])
where(condition)
end
|
#for_project(project) ⇒ Object
31
32
33
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 31
def for_project(project)
where(path: project.project_namespace.traversal_path)
end
|
#for_ref(ref) ⇒ Object
39
40
41
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 39
def for_ref(ref)
where(ref: ref)
end
|
#for_source(source) ⇒ Object
35
36
37
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 35
def for_source(source)
where(source: source)
end
|
#group_by_status ⇒ Object
68
69
70
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 68
def group_by_status
group(@query_builder.table[:status])
end
|
#group_by_timestamp_bin ⇒ Object
72
73
74
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 72
def group_by_timestamp_bin
group(timestamp_alias)
end
|
#timestamp_bin_function(time_series_period) ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 76
def timestamp_bin_function(time_series_period)
Arel::Nodes::NamedFunction.new(
'dateTrunc',
[
Arel::Nodes.build_quoted(time_series_period.to_s),
@query_builder.table[:started_at_bucket],
timezone
]
).as(timestamp_alias)
end
|
#within_dates(from_time, to_time) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/click_house/models/ci/finished_pipelines_base.rb', line 52
def within_dates(from_time, to_time)
query = self
started_at_bucket = @query_builder.table[:started_at_bucket]
query = query.where(started_at_bucket.gteq(format_time(from_time))) if from_time
query = query.where(started_at_bucket.lt(format_time(to_time))) if to_time
query
end
|