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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: baff087d473033855f592778306a9d7c85b03b86fd0d004e34a440ae3a0f7c74
4
- data.tar.gz: 227d3223cc8e8bce298103c24fda66ab29ed96120505370d82b4df4d77aac89a
3
+ metadata.gz: 975d555ef042a9a73b6ab118893549d94be5f3ef8ff99ddfbd0d7ccbf7c2893f
4
+ data.tar.gz: 5fe6bb402f0ca316cb0fad3f3a976efede13bfce77ae73bfd567d18532b7f02b
5
5
  SHA512:
6
- metadata.gz: c2fd84911b2f05e6aa2559825169007eed8e621f434b81edffd7a58e89d7c06d584d34070f44bbed7667b3ba8e01010b51177478525d68e7c13327a8c976a97a
7
- data.tar.gz: fedc5ce8adf0b72a57d1d2e8631626aafca24ccff2cbd125c510a47ebf0b165f71b0dafb72afc8e0927ec5aed47fbf10da2f1f22f1706797b82a3101e8e3bd15
6
+ metadata.gz: d40fcdaba6b1f6884116c14bce2e4749da68b1a4e7b21db24b53fd177373327d140ffc8ea1e3fef9c0e619889a033e022338d9243cbabaad05c1d3fb43904288
7
+ data.tar.gz: 6acc57076ca5d1dae4e5fa49fd66edf4220a981e799b14b2cff786aadf65714e91a6729cd57a98814219488f81f37c03fb42b6578eada35b287e0e031d6fd10d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twstats (0.2)
4
+ twstats (0.2.1)
5
5
  rainbow (~> 3.0)
6
6
  tty-prompt (~> 0.17)
7
7
 
@@ -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\n"
11
+ ***************************************************************************************\n"
12
12
  STATS_MENU_CHOICES = [
13
- {name: 'Projects', value: 0},
14
- {name: 'People', value: 1},
15
- {name: 'Tags', value: 2},
16
- {name: 'Full stats', value: 3},
17
- {name: 'Back', value: 4}
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: 0},
21
- {name: 'Info', value: 1},
22
- {name: 'Quit', value: 2}
21
+ {name: 'Stats', value: :stats},
22
+ {name: 'Info', value: :info},
23
+ {name: 'Quit', value: :quit}
23
24
  ]
24
25
  end
@@ -69,5 +69,10 @@ module Twstats
69
69
  return billable + non_billable
70
70
  end
71
71
  end
72
+
73
+ def is_weekly?
74
+ sorted_logs = logs.map{|l| l.date}.sort
75
+ (sorted_logs[-1] - sorted_logs[0]).to_i <= 7
76
+ end
72
77
  end
73
78
  end
@@ -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 0
21
+ when :stats
22
22
  show_stats_menu
23
- when 1
23
+ when :info
24
24
  show_info
25
- when 2
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 0
38
- show_stats :projects
39
- when 1
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 4
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.P. Araque