Class: Ci::Charts::Chart

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/charts.rb

Direct Known Subclasses

BuildTime, MonthChart, WeekChart, YearChart

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Chart

Returns a new instance of Chart


6
7
8
9
10
11
12
13
14
# File 'lib/ci/charts.rb', line 6

def initialize(project)
  @labels = []
  @total = []
  @success = []
  @build_times = []
  @project = project

  collect
end

Instance Attribute Details

#build_timesObject (readonly)

Returns the value of attribute build_times


4
5
6
# File 'lib/ci/charts.rb', line 4

def build_times
  @build_times
end

#labelsObject (readonly)

Returns the value of attribute labels


4
5
6
# File 'lib/ci/charts.rb', line 4

def labels
  @labels
end

#projectObject (readonly)

Returns the value of attribute project


4
5
6
# File 'lib/ci/charts.rb', line 4

def project
  @project
end

#successObject (readonly)

Returns the value of attribute success


4
5
6
# File 'lib/ci/charts.rb', line 4

def success
  @success
end

#totalObject (readonly)

Returns the value of attribute total


4
5
6
# File 'lib/ci/charts.rb', line 4

def total
  @total
end

Instance Method Details

#push(from, to, format) ⇒ Object


17
18
19
20
21
22
23
24
25
# File 'lib/ci/charts.rb', line 17

def push(from, to, format)
  @labels << from.strftime(format)
  @total << project.builds.
    where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", to, from).
    count(:all)
  @success << project.builds.
    where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", to, from).
    success.count(:all)
end