worktrack 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +22 -21
  2. data/lib/worktrack.rb +69 -12
  3. metadata +2 -2
data/README.md CHANGED
@@ -22,30 +22,31 @@ Running the command
22
22
 
23
23
  worktrack -show
24
24
 
25
- will show a list of changes made like this:
25
+ will show a list of changes made on the month before and the current month like this:
26
26
 
27
27
  worktrack - another great nedeco idea
28
+ 5807 changes in 7 Repositories
29
+
30
+ calculation timeframe from 2013-01-01 00:00:00 UTC until 2013-02-01 00:00:00 UTC
31
+ Total minutes worked: 0
32
+ calculation timeframe from 2013-02-01 00:00:00 UTC until 2013-02-19 22:28:15 +0100
33
+ worktrack
34
+ 52 minutes 2013-02-16 22:09:07 +0100 - 2013-02-16 23:01:56 +0100
35
+ 37 minutes 2013-02-18 00:18:49 +0100 - 2013-02-18 00:56:06 +0100
36
+ puppet
37
+ 15 minutes 2013-02-17 09:32:39 +0100 - 2013-02-17 09:47:44 +0100
38
+ 15 minutes 2013-02-18 12:12:45 +0100 - 2013-02-18 12:28:28 +0100
39
+ rollout_admin
40
+ 15 minutes 2013-02-18 15:28:10 +0100 - 2013-02-18 15:43:11 +0100
41
+ 25 minutes 2013-02-19 07:07:39 +0100 - 2013-02-19 07:33:29 +0100
42
+ admin-interface
43
+ 60 minutes 2013-02-19 07:50:06 +0100 - 2013-02-19 08:50:15 +0100
44
+ 52 minutes 2013-02-19 09:32:38 +0100 - 2013-02-19 10:24:46 +0100
45
+ 16 minutes 2013-02-19 10:41:08 +0100 - 2013-02-19 10:57:47 +0100
46
+ syslog-analyzer
47
+ 95 minutes 2013-02-19 13:44:37 +0100 - 2013-02-19 15:20:01 +0100
48
+ Total minutes worked: 382
28
49
 
29
- 18 changes in 1 Repositories
30
- worktrack:
31
- test added on 2013-02-16 22:09:07 +0100
32
- test removed on 2013-02-16 22:09:08 +0100
33
- worktrack.rb modified on 2013-02-16 22:15:16 +0100
34
- worktrack.rb modified on 2013-02-16 22:15:36 +0100
35
- worktrack.rb modified on 2013-02-16 22:16:29 +0100
36
- worktrack.rb modified on 2013-02-16 22:16:31 +0100
37
- worktrack.rb modified on 2013-02-16 22:16:40 +0100
38
- worktrack.rb modified on 2013-02-16 22:16:55 +0100
39
- index modified on 2013-02-16 22:19:26 +0100
40
- d177bb10f5dbc889c1c4a273ff36b1e8a7e77b added on 2013-02-16 22:19:26 +0100
41
- COMMIT_EDITMSG modified on 2013-02-16 22:19:33 +0100
42
- index modified on 2013-02-16 22:19:33 +0100
43
- b894001457bf96372e39512655f1303332d9c2 added on 2013-02-16 22:19:33 +0100
44
- 2c9d823c762424fa79ad53b693e1c9edcc5b1b added on 2013-02-16 22:19:33 +0100
45
- master modified on 2013-02-16 22:19:33 +0100
46
- master modified on 2013-02-16 22:19:33 +0100
47
- HEAD modified on 2013-02-16 22:19:33 +0100
48
- 5faa2138e310a1b86f129e00b9fa03f3bf94fe added on 2013-02-16 22:19:33 +0100
49
50
 
50
51
  ###Credits
51
52
 
data/lib/worktrack.rb CHANGED
@@ -85,20 +85,77 @@ class WorkTrack
85
85
  }
86
86
  end
87
87
 
88
- def dump_changes()
89
- puts "worktrack - another great nedeco idea\n\n"
90
- puts "#{Change.all.count} changes in #{Repo.all.count} Repositories"
91
-
92
- if Repo.all.count == 0
93
- puts "go and do some work before you want to earn respect"
94
- else
95
- Repo.all.each {|rep|
96
- puts "#{rep.name}:"
97
- rep.changes.each {|change|
98
- puts "\t #{change.filename} #{change.action} on #{change.timestamp}"
99
- }
88
+ def prettyprint(work_frames)
89
+ # make some nice output
90
+ if !work_frames.nil?
91
+ @totalmin=0
92
+ work_frames.each {|rep|
93
+ if !rep.nil? && !rep.empty?
94
+ puts "#{rep.first[:repository]}"
95
+ rep.each {|work|
96
+ puts "\t#{work[:amount]} minutes #{work[:from]} - #{work[:to]}"
97
+ @totalmin = @totalmin + work[:amount]
98
+ }
99
+ end
100
100
  }
101
+ puts "Total minutes worked: #{@totalmin}"
102
+ end
103
+ end
104
+
105
+
106
+ def calctimeframe(from, to)
107
+ puts "calculation timeframe from #{from} until #{to}\n"
108
+ @work_frames=[]
109
+ Repo.all.each {|rep|
110
+ @work_frames[rep.id] = []
111
+ }
112
+ @last_repo=0
113
+ @last_time=0
114
+ @starttime=0
115
+ @endtime=0
116
+
117
+ # 15 minutes by 60 seconds
118
+ @corridor=15*60
119
+
120
+ @DB.fetch("select * from changes where timestamp > '#{from}' and timestamp < '#{to}' order by repo_id") do |c|
121
+ if (c[:repo_id] != @last_repo)
122
+ @last_repo=c[:repo_id]
123
+ @last_time=-1
124
+ if @starttime > 0
125
+ @endtime = @starttime + @corridor unless @endtime > 0
126
+ @rep=Repo.where(:id => @last_repo).first
127
+ @work_frames[@last_repo] << {:repository => @rep.name, :from => Time.at(@starttime), :to => Time.at(@endtime), :amount => (@endtime - @starttime)/60 }
128
+ end
129
+ @endtime=0
130
+ @starttime=0
131
+ end
132
+ unless @starttime > 0
133
+ @starttime=c[:timestamp].to_i
134
+ @endtime=@starttime+@corridor
135
+ end
136
+
137
+ if c[:timestamp].to_i < (@endtime + @corridor)
138
+ @endtime=c[:timestamp].to_i + @corridor
139
+ else
140
+ @rep=Repo.where(:id => @last_repo).first
141
+ @work_frames[@last_repo] << {:repository => @rep.name, :from => Time.at(@starttime), :to => Time.at(@endtime), :amount => (@endtime - @starttime)/60 }
142
+ @starttime=c[:timestamp].to_i
143
+ @endtime=@starttime + @corridor
144
+ end
145
+ @last_time += 1
101
146
  end
147
+
148
+ prettyprint(@work_frames)
149
+
150
+ end
151
+
152
+ def dump_changes()
153
+ puts "worktrack - another great nedeco idea\n"
154
+ puts "#{Change.all.count} changes in #{Repo.all.count} Repositories\n\n"
155
+
156
+ calctimeframe(Time.utc(Time.new.year, Time.new.month-1),Time.utc(Time.new.year, Time.new.month))
157
+ calctimeframe(Time.utc(Time.new.year, Time.new.month),Time.now)
158
+
102
159
  end
103
160
 
104
161
  def run
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worktrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-16 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: listen