twstats 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/twstats.rb +10 -9
- data/lib/twstats/csv_reader.rb +5 -0
- data/lib/twstats/runner.rb +34 -11
- data/lib/twstats/tw_log.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 975d555ef042a9a73b6ab118893549d94be5f3ef8ff99ddfbd0d7ccbf7c2893f
|
4
|
+
data.tar.gz: 5fe6bb402f0ca316cb0fad3f3a976efede13bfce77ae73bfd567d18532b7f02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40fcdaba6b1f6884116c14bce2e4749da68b1a4e7b21db24b53fd177373327d140ffc8ea1e3fef9c0e619889a033e022338d9243cbabaad05c1d3fb43904288
|
7
|
+
data.tar.gz: 6acc57076ca5d1dae4e5fa49fd66edf4220a981e799b14b2cff786aadf65714e91a6729cd57a98814219488f81f37c03fb42b6578eada35b287e0e031d6fd10d
|
data/Gemfile.lock
CHANGED
data/lib/twstats.rb
CHANGED
@@ -8,17 +8,18 @@ module Twstats
|
|
8
8
|
DEFAULT_OPTIONS = {encoding: 'ISO-8859-1:UTF-8', headers: true}
|
9
9
|
WELLCOME_MESSAGE = "\n***************************************************************************************
|
10
10
|
** TWStats helps you to get some stats from a CSV export of Time loggin gin Teamwork **
|
11
|
-
***************************************************************************************\n
|
11
|
+
***************************************************************************************\n"
|
12
12
|
STATS_MENU_CHOICES = [
|
13
|
-
{name: 'Projects', value:
|
14
|
-
{name: 'People', value:
|
15
|
-
{name: 'Tags', value:
|
16
|
-
{name: 'Full stats', value:
|
17
|
-
{name: '
|
13
|
+
{name: 'Projects', value: :projects},
|
14
|
+
{name: 'People', value: :people},
|
15
|
+
{name: 'Tags', value: :tags},
|
16
|
+
{name: 'Full stats', value: :fullstats},
|
17
|
+
{name: 'Weekly', value: :weekly},
|
18
|
+
{name: 'Back', value: :back}
|
18
19
|
]
|
19
20
|
MENU_CHOICES = [
|
20
|
-
{name: 'Stats', value:
|
21
|
-
{name: 'Info', value:
|
22
|
-
{name: 'Quit', value:
|
21
|
+
{name: 'Stats', value: :stats},
|
22
|
+
{name: 'Info', value: :info},
|
23
|
+
{name: 'Quit', value: :quit}
|
23
24
|
]
|
24
25
|
end
|
data/lib/twstats/csv_reader.rb
CHANGED
data/lib/twstats/runner.rb
CHANGED
@@ -18,11 +18,11 @@ module Twstats
|
|
18
18
|
loop do
|
19
19
|
option = @prompt.select("Choose an option", Twstats::MENU_CHOICES, cycle: true)
|
20
20
|
case option
|
21
|
-
when
|
21
|
+
when :stats
|
22
22
|
show_stats_menu
|
23
|
-
when
|
23
|
+
when :info
|
24
24
|
show_info
|
25
|
-
when
|
25
|
+
when :quit
|
26
26
|
break
|
27
27
|
else
|
28
28
|
puts 'Option not recognized!'
|
@@ -34,15 +34,13 @@ module Twstats
|
|
34
34
|
loop do
|
35
35
|
option = @prompt.select("Select what time logging stats you want to see", Twstats::STATS_MENU_CHOICES, cycle: true)
|
36
36
|
case option
|
37
|
-
when
|
38
|
-
show_stats
|
39
|
-
when
|
40
|
-
show_stats :people
|
41
|
-
when 2
|
42
|
-
show_stats :tags
|
43
|
-
when 3
|
37
|
+
when :projects, :people, :tags
|
38
|
+
show_stats option
|
39
|
+
when :fullstats
|
44
40
|
show_full_stats
|
45
|
-
when
|
41
|
+
when :weekly
|
42
|
+
show_weekly_report
|
43
|
+
when :back
|
46
44
|
return
|
47
45
|
else
|
48
46
|
puts 'Option not recognized'
|
@@ -104,5 +102,30 @@ module Twstats
|
|
104
102
|
puts " - Mean time logged: ".bright.blue + mean.round(2).to_s
|
105
103
|
puts " - Mean time per task: ".bright.blue + mean_per_task.round(2).to_s
|
106
104
|
end
|
105
|
+
|
106
|
+
def show_weekly_report
|
107
|
+
unless @csv.is_weekly?
|
108
|
+
puts 'The CSV file provided has logged times that differ more than a week.'
|
109
|
+
unless @prompt.ask 'Are you sure you want to continue?', default: true
|
110
|
+
return
|
111
|
+
end
|
112
|
+
end
|
113
|
+
hours = @prompt.ask 'What is the weekly amount of hours worked?', default: 40, convert: :float
|
114
|
+
info = {}
|
115
|
+
@csv.people.each do |person|
|
116
|
+
billable, non_billable = @csv.get_total_time(:people, person, true)
|
117
|
+
info[person] = {rate: billable * 100 / hours,
|
118
|
+
not_billed: hours - billable - non_billable,
|
119
|
+
billable: billable,
|
120
|
+
non_billable: non_billable
|
121
|
+
}
|
122
|
+
end
|
123
|
+
info.sort_by{|x,v| v[:rate] }.reverse.each do |person, data|
|
124
|
+
puts " - " + person.bright.blue
|
125
|
+
puts "\tBillable time: ".ljust(20, ' ').bright + data[:billable].round(2).to_s
|
126
|
+
puts "\tBillable rate: ".ljust(20, ' ').bright + data[:rate].round(2).to_s + ' % '
|
127
|
+
puts "\tNot logged time: ".ljust(20, ' ').bright + data[:not_billed].round(2).to_s
|
128
|
+
end
|
129
|
+
end
|
107
130
|
end
|
108
131
|
end
|
data/lib/twstats/tw_log.rb
CHANGED
@@ -5,6 +5,7 @@ module Twstats
|
|
5
5
|
attr_reader :time
|
6
6
|
attr_reader :decimal_time
|
7
7
|
attr_reader :description
|
8
|
+
attr_reader :date
|
8
9
|
attr_reader :tags
|
9
10
|
attr_reader :project
|
10
11
|
attr_reader :task
|
@@ -22,6 +23,7 @@ module Twstats
|
|
22
23
|
@project = row["Project"]
|
23
24
|
@task = row["Task"]
|
24
25
|
@billable = !row["Is it Billable?"].to_i.zero?
|
26
|
+
@date = DateTime.parse(row['Date'])
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|