tempest_time 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tempest_time/api/tempo_api/requests/create_worklog.rb +1 -1
- data/lib/tempest_time/command.rb +5 -4
- data/lib/tempest_time/commands/list.rb +20 -15
- data/lib/tempest_time/commands/track.rb +26 -7
- data/lib/tempest_time/helpers/time_helper.rb +16 -3
- data/lib/tempest_time/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b895b41af4c2e73bd189b4ff68606b3f032b02
|
4
|
+
data.tar.gz: 95548d0b3807c5975808640714ee9d8cb5e6a450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c947e642c9ac21e6762060a2b97bfd1dbbff1e095e0ee9015d0f03b844d7eadcf22869b667834f53a8ec5d57fda4cd3c8780b4179504412f48d4fd875ab07bf
|
7
|
+
data.tar.gz: 1fb03ccc8bc8a8b81bc581854351844aab2e59553b17f5f4ddfa500ba44b0decbcaf51e570bf0ea6ac8e2442b9b08ad204a0d533d91ee809ee18a373d2b84a6d
|
@@ -10,7 +10,7 @@ module TempoAPI
|
|
10
10
|
@remaining = options['remaining']
|
11
11
|
@issue = options['issue']
|
12
12
|
@message = options['message']
|
13
|
-
@date = options['date'] ?
|
13
|
+
@date = options['date'] ? options['date'] : Date.today
|
14
14
|
@billable = options['billable']
|
15
15
|
end
|
16
16
|
|
data/lib/tempest_time/command.rb
CHANGED
@@ -53,13 +53,14 @@ module TempestTime
|
|
53
53
|
)
|
54
54
|
end
|
55
55
|
|
56
|
-
def date_prompt(message,
|
56
|
+
def date_prompt(message, days_before: 3, days_after: 3)
|
57
57
|
require 'tty-prompt'
|
58
|
-
dates =
|
59
|
-
TTY::Prompt.new.
|
58
|
+
dates = dates_in_range(days_before: days_before, days_after: days_after)
|
59
|
+
TTY::Prompt.new.multi_select(
|
60
60
|
message,
|
61
61
|
dates,
|
62
|
-
per_page: 5
|
62
|
+
per_page: 5,
|
63
|
+
default: dates.find_index { |k, v| v == Date.today } + 1
|
63
64
|
)
|
64
65
|
end
|
65
66
|
|
@@ -8,24 +8,29 @@ module TempestTime
|
|
8
8
|
class List < TempestTime::Command
|
9
9
|
def initialize(options)
|
10
10
|
@user = options[:user]
|
11
|
-
@
|
11
|
+
@dates = options[:date] ? [Date.parse(options[:date])] : nil
|
12
12
|
end
|
13
13
|
|
14
14
|
def execute!
|
15
|
-
@
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
@dates ||= date_prompt(
|
16
|
+
'Please select the dates you wish to view.',
|
17
|
+
days_before: 13,
|
18
|
+
days_after: 13
|
19
|
+
).sort
|
20
|
+
@dates.each do |date|
|
21
|
+
with_spinner("Retrieving logs for #{pastel.yellow(formatted_date(date))}...") do |spin|
|
22
|
+
@response = TempoAPI::Requests::ListWorklogs.new(
|
23
|
+
date,
|
24
|
+
end_date: nil,
|
25
|
+
requested_user: @user
|
26
|
+
).send_request
|
27
|
+
spin.stop(pastel.green('Done!'))
|
28
|
+
prompt.say(render_table)
|
29
|
+
prompt.say(
|
30
|
+
'Total Time Logged: '\
|
31
|
+
"#{pastel.green("#{@response.total_hours_spent} hours")}"
|
32
|
+
)
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -13,17 +13,19 @@ module TempestTime
|
|
13
13
|
@options = options
|
14
14
|
@issues = issues.any? ? issues.map(&:upcase) : [automatic_issue]
|
15
15
|
@time = parsed_time(time) / @issues.count
|
16
|
+
@dates = options[:date] ? [Date.parse(options[:date])] : nil
|
16
17
|
end
|
17
18
|
|
18
19
|
def execute!
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
dates
|
21
|
+
unless options[:autoconfirm]
|
22
|
+
confirm_prompt
|
23
|
+
end
|
24
|
+
dates.each do |date|
|
25
|
+
issues.each do |issue|
|
26
|
+
track_time(time, options.merge({ issue: issue, date: date }))
|
27
|
+
end
|
24
28
|
end
|
25
|
-
|
26
|
-
issues.each { |issue| track_time(time, options.merge('issue' => issue)) }
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
@@ -40,6 +42,23 @@ module TempestTime
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
45
|
+
def dates
|
46
|
+
@dates ||= if options[:autoconfirm]
|
47
|
+
[Date.today]
|
48
|
+
else
|
49
|
+
date_prompt("Select the day(s) to log this time to.",
|
50
|
+
days_before: 13,
|
51
|
+
days_after: 365).sort
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def confirm_prompt
|
56
|
+
prompt_message = "Track #{formatted_time(time)}, "\
|
57
|
+
"#{billability(options)}, "\
|
58
|
+
"to #{issues.join(', ')}?"
|
59
|
+
abort unless prompt.yes?(prompt_message, convert: :bool)
|
60
|
+
end
|
61
|
+
|
43
62
|
def remaining_estimate(issue, time)
|
44
63
|
request = JiraAPI::Requests::GetIssue.new(issue)
|
45
64
|
request.send_request
|
@@ -64,10 +64,23 @@ module TempestTime
|
|
64
64
|
weeks
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def dates_in_range(days_before: 0, days_after: 0)
|
68
|
+
future_dates(days_after).merge(past_dates(days_before))
|
69
|
+
end
|
70
|
+
|
71
|
+
def past_dates(number_of_days)
|
72
|
+
dates = {}
|
73
|
+
(0..number_of_days).each do |num|
|
74
|
+
date = Date.today - num
|
75
|
+
dates[formatted_date(date)] = date
|
76
|
+
end
|
77
|
+
dates
|
78
|
+
end
|
79
|
+
|
80
|
+
def future_dates(number_of_days)
|
68
81
|
dates = {}
|
69
|
-
(0
|
70
|
-
date = Date.today
|
82
|
+
number_of_days.downto(0).each do |num|
|
83
|
+
date = Date.today + num
|
71
84
|
dates[formatted_date(date)] = date
|
72
85
|
end
|
73
86
|
dates
|
data/lib/tempest_time/version.rb
CHANGED