mirror of
https://github.com/tomgi/git_stats.git
synced 2024-09-21 00:41:29 +02:00
activity stats
This commit is contained in:
parent
1203e33f3d
commit
f073464251
@ -1,6 +1,6 @@
|
||||
require 'git_stats/git_data'
|
||||
require 'git_stats/assets'
|
||||
require 'git_stats/template'
|
||||
require 'git_stats/git_data/git_data'
|
||||
require 'git_stats/template/assets'
|
||||
require 'git_stats/template/template'
|
||||
|
||||
class GitStats::Generator
|
||||
def initialize(repo_path, out_path)
|
||||
|
13
lib/git_stats/git_data/git_activity.rb
Normal file
13
lib/git_stats/git_data/git_activity.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class GitStats::GitActivity
|
||||
def by_hour
|
||||
@by_hour ||= Hash.new(0)
|
||||
end
|
||||
|
||||
def by_wday
|
||||
@by_wday ||= Hash.new(0)
|
||||
end
|
||||
|
||||
def by_wday_hour
|
||||
@by_wday_hour ||= Hash.new { |h, k| h[k] = Hash.new(0) }
|
||||
end
|
||||
end
|
@ -1,6 +1,7 @@
|
||||
require 'pathname'
|
||||
require 'git_stats/git_author'
|
||||
require 'git_stats/git_commit'
|
||||
require 'git_stats/git_data/git_activity'
|
||||
require 'git_stats/git_data/git_author'
|
||||
require 'git_stats/git_data/git_commit'
|
||||
|
||||
class GitStats::GitData
|
||||
attr_reader :total_authors
|
||||
@ -19,10 +20,20 @@ class GitStats::GitData
|
||||
def gather_commit_data
|
||||
run('git rev-list --pretty=format:"%h|%at|%ai|%aN|%aE" HEAD | grep -v commit').split(/\r?\n/).each do |commit|
|
||||
hash, stamp, date, author_name, author_email = commit.split('|')
|
||||
|
||||
authors[author_email] = GitStats::GitAuthor.new(name: author_name, email: author_email) unless authors[author_email]
|
||||
author = authors[author_email]
|
||||
|
||||
date = DateTime.parse(date)
|
||||
commits[hash] = GitStats::GitCommit.new(hash: hash, stamp: stamp, date: date, author: author)
|
||||
|
||||
activity.by_hour[date.hour] += 1
|
||||
activity.by_wday[date.wday] += 1
|
||||
activity.by_wday_hour[date.wday][date.hour] += 1
|
||||
end
|
||||
|
||||
require 'pry'
|
||||
binding.pry
|
||||
end
|
||||
|
||||
def authors
|
||||
@ -33,6 +44,10 @@ class GitStats::GitData
|
||||
@commits ||= {}
|
||||
end
|
||||
|
||||
def activity
|
||||
@activity ||= GitStats::GitActivity.new
|
||||
end
|
||||
|
||||
def project_version
|
||||
@project_version ||= run('git rev-parse --short HEAD')
|
||||
end
|
Loading…
Reference in New Issue
Block a user