Class: Gitlab::Ci::Charts::Chart
- Inherits:
-
Object
- Object
- Gitlab::Ci::Charts::Chart
- Defined in:
- lib/gitlab/ci/charts.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#pipeline_times ⇒ Object
readonly
Returns the value of attribute pipeline_times.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#collect ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
-
#initialize(project) ⇒ Chart
constructor
A new instance of Chart.
Constructor Details
#initialize(project) ⇒ Chart
Returns a new instance of Chart.
39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/ci/charts.rb', line 39 def initialize(project) @labels = [] @total = [] @success = [] @pipeline_times = [] @project = project collect end |
Instance Attribute Details
#labels ⇒ Object (readonly)
Returns the value of attribute labels
37 38 39 |
# File 'lib/gitlab/ci/charts.rb', line 37 def labels @labels end |
#pipeline_times ⇒ Object (readonly)
Returns the value of attribute pipeline_times
37 38 39 |
# File 'lib/gitlab/ci/charts.rb', line 37 def pipeline_times @pipeline_times end |
#project ⇒ Object (readonly)
Returns the value of attribute project
37 38 39 |
# File 'lib/gitlab/ci/charts.rb', line 37 def project @project end |
#success ⇒ Object (readonly)
Returns the value of attribute success
37 38 39 |
# File 'lib/gitlab/ci/charts.rb', line 37 def success @success end |
#total ⇒ Object (readonly)
Returns the value of attribute total
37 38 39 |
# File 'lib/gitlab/ci/charts.rb', line 37 def total @total end |
Instance Method Details
#collect ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gitlab/ci/charts.rb', line 50 def collect query = project.all_pipelines .where("? > #{::Ci::Pipeline.table_name}.created_at AND #{::Ci::Pipeline.table_name}.created_at > ?", @to, @from) # rubocop:disable GitlabSecurity/SqlInjection totals_count = grouped_count(query) success_count = grouped_count(query.success) current = @from while current < @to label = current.strftime(@format) @labels << label @total << (totals_count[label] || 0) @success << (success_count[label] || 0) current += interval_step end end |