Class: Metior::Report::Default::Impact
- Inherits:
-
View
- Object
- Mustache
- View
- Metior::Report::Default::Impact
show all
- Defined in:
- reports/default/views/impact.rb
Overview
Instance Method Summary
(collapse)
Methods inherited from View
inherited, #init, #initialize, #method_missing, partial, #render, #repository, requires, #respond_to_missing?, #vcs_id
Methods included from ViewHelper
#count, #even_odd, #reset_count
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Metior::Report::View
Instance Method Details
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'reports/default/views/impact.rb', line 16
def data
commits = @report.commits
return '{}' if commits.empty?
authors = commits.authors
author_indices = {}
authors.each_with_index { |author, index| author_indices[author.id] = index }
first = commits.last.committed_date.send :to_date
last = commits.first.committed_date.send :to_date
first_monday = first - (first.wday - 1)
impact_data = []
first_monday.step(last, 7) do |week|
next_week = (week + 7).to_time
week_commits = commits.before next_week
commits = commits.after next_week
week_data = { :d => week.to_time.to_i }
week_data[:i] = []
week_commits.authors.each do |author|
week_data[:i] << [ author_indices[author.id], week_commits.by(author.id).modifications ]
end
impact_data << week_data
end
author_data = {}
authors.each do |author|
author_data[author_indices[author.id]] = {
:n => author.name,
:c => author.commits.size,
:a => author.commits.additions,
:d => author.commits.deletions
}
end
MultiJson.encode({ :authors => author_data, :buckets => impact_data })
end
|
56
57
58
|
# File 'reports/default/views/impact.rb', line 56
def meta_now
now.strftime('%FT%H:%M:%S%z').insert(-3, ':')
end
|
60
61
62
|
# File 'reports/default/views/impact.rb', line 60
def now
Time.now
end
|
- (Object) repo_name
64
65
66
|
# File 'reports/default/views/impact.rb', line 64
def repo_name
repository.name.empty? ? repository.path : repository.name
end
|
68
69
70
|
# File 'reports/default/views/impact.rb', line 68
def title
"Impact graph for #{repo_name}"
end
|
72
73
74
|
# File 'reports/default/views/impact.rb', line 72
def version
Metior::VERSION
end
|