Class: Diggit::DevelopersActivity::Analyses::ProjectDevelopersAnalysis

Inherits:
ActivityAnalysis
  • Object
show all
Defined in:
lib/diggit/developers_activity/analyses/project_developers_analysis.rb

Overview

Records the activity of developers at the project level, ie, the date at which developers commit

Since:

  • 0.0.1

Instance Method Summary collapse

Methods inherited from ActivityAnalysis

#initialize, #load_options, #source_options

Methods included from Diggit::DevelopersActivity::ActivityExtractor

#extract_developers_activity

Constructor Details

This class inherits a constructor from Diggit::DevelopersActivity::Analyses::ActivityAnalysis

Instance Method Details

#cleanObject

Since:

  • 0.0.1



33
34
35
# File 'lib/diggit/developers_activity/analyses/project_developers_analysis.rb', line 33

def clean
  @addons[:db].db[COL].remove({ project: @source })
end

#runObject

Since:

  • 0.0.1



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/diggit/developers_activity/analyses/project_developers_analysis.rb', line 13

def run
  r_last = @repo.lookup(source_options["R_last"])
  r_first_time = @repo.lookup(source_options["R_first"]).author[:time]

  walker = Rugged::Walker.new(@repo)
  walker.sorting(Rugged::SORT_DATE)
  walker.push(r_last)

  devs = []
  walker.each do |commit|
    t = commit.author[:time]
    author = Authors.get_author(commit)
    devs << { project: @source, author: author, time: t }

    break if t < r_first_time
  end

  @addons[:db].db[COL].insert(devs)
end