Class: Hubba::ReportTimeline

Inherits:
Report
  • Object
show all
Defined in:
lib/hubba/reports/reports/timeline.rb

Instance Method Summary collapse

Methods inherited from Report

#initialize, #save

Constructor Details

This class inherits a constructor from Hubba::Report

Instance Method Details

#buildObject



6
7
8
9
10
11
12
13
14
15
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
# File 'lib/hubba/reports/reports/timeline.rb', line 6

def build
## create a (timeline report)

## note: orgs is orgs+users e.g. geraldb, yorobot etc
buf = String.new('')
buf << "# Timeline"
buf << " - #{@stats.repos.size} Repos @ #{@stats.orgs.size} Orgs"
buf << "\n\n"


repos = @stats.repos.sort do |l,r|
  ## note: use reverse sort (right,left) - e.g. most stars first
  ## r[:stars] <=> l[:stars]

  ## sort by created_at (use julian days)
  r.stats.created.jd <=> l.stats.created.jd
end


## pp repos


last_year  = -1
last_month = -1

repos.each_with_index do |repo,i|
  year       = repo.stats.created.year
  month      = repo.stats.created.month

  if last_year != year
    buf << "\n## #{year}\n\n"
  end

  if last_month != month
    buf << "\n### #{month}\n\n"
  end

  last_year  = year
  last_month = month

  buf << "- #{repo.stats.created_at.strftime('%Y-%m-%d')}#{repo.stats.stars} **#{repo.full_name}** (#{repo.stats.size} kb)\n"
end

buf
end