pager_judy 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/pager_judy/api/client.rb +4 -0
- data/lib/pager_judy/cli/main_command.rb +45 -7
- data/lib/pager_judy/cli/time_filtering.rb +10 -2
- data/lib/pager_judy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e4b53112f40137b435f917ebc2a692616c25863b2f90ea9f7d78c26b9386f0
|
4
|
+
data.tar.gz: 6d668eb10ba3e4ca97de5c33decf84b71c701113341851d9ea1a197df1108b31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be237a110f748b9463a11325d926eee6128dabba944aaaf1f31472d95c4b8dc52ef82ffa41670098ebb091171b915fe197262d86bd3b09a4e6338f906ec00b5d
|
7
|
+
data.tar.gz: efce178cd54cd9cce9a4dd84a52ef73b8e00b5ee05aa66ef2354990a6373d4b4aebe5c379e8bdfb9bbe0e5519d1b1ef30cb5a9cdf9bebd498228b72b83fe67b6
|
data/CHANGES.md
CHANGED
@@ -87,6 +87,36 @@ module PagerJudy
|
|
87
87
|
|
88
88
|
end
|
89
89
|
|
90
|
+
subcommand ["log-entries", "logs"], "Display log entries" do
|
91
|
+
|
92
|
+
include TimeFiltering
|
93
|
+
|
94
|
+
self.default_subcommand = "summary"
|
95
|
+
|
96
|
+
subcommand ["summary", "s"], "One-line summary" do
|
97
|
+
|
98
|
+
def execute
|
99
|
+
collection.each do |entry|
|
100
|
+
ts = Time.parse(entry.fetch("created_at"))
|
101
|
+
ts_string = ts.localtime.strftime("%Y-%m-%d %H:%M")
|
102
|
+
incident = entry.dig("incident", "summary")
|
103
|
+
event = entry.dig("summary")
|
104
|
+
puts "#{ts_string}: #{incident} - #{event}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
subcommand ["data", "d"], "Full details" do
|
111
|
+
include CollectionBehaviour::DataSubcommand
|
112
|
+
end
|
113
|
+
|
114
|
+
def collection
|
115
|
+
client.log_entries.with(time_filters)
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
90
120
|
subcommand ["notifications"], "Display notifications" do
|
91
121
|
|
92
122
|
include TimeFiltering
|
@@ -103,7 +133,7 @@ module PagerJudy
|
|
103
133
|
|
104
134
|
end
|
105
135
|
|
106
|
-
subcommand "oncalls", "Display those currently on-call" do
|
136
|
+
subcommand ["oncalls", "oncall"], "Display those currently on-call" do
|
107
137
|
|
108
138
|
include TimeFiltering
|
109
139
|
|
@@ -134,12 +164,12 @@ module PagerJudy
|
|
134
164
|
|
135
165
|
def format_time_range(from, to)
|
136
166
|
bits = [from.strftime("%Y-%m-%d %H:%M")]
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
167
|
+
bits << if to.nil?
|
168
|
+
"..."
|
169
|
+
elsif to.to_date == from.to_date
|
170
|
+
to.strftime("%H:%M")
|
171
|
+
else
|
172
|
+
to.strftime("%Y-%m-%d %H:%M")
|
143
173
|
end
|
144
174
|
bits.join(" - ")
|
145
175
|
end
|
@@ -155,6 +185,14 @@ module PagerJudy
|
|
155
185
|
client.oncalls.with(filters)
|
156
186
|
end
|
157
187
|
|
188
|
+
def default_after
|
189
|
+
Time.now
|
190
|
+
end
|
191
|
+
|
192
|
+
def default_before
|
193
|
+
Time.now
|
194
|
+
end
|
195
|
+
|
158
196
|
def other_filters
|
159
197
|
{
|
160
198
|
"user_ids[]" => user_list,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "clamp"
|
2
2
|
require "time"
|
3
3
|
|
4
|
+
|
4
5
|
module PagerJudy
|
5
6
|
module CLI
|
6
7
|
|
@@ -13,6 +14,13 @@ module PagerJudy
|
|
13
14
|
option %w[-a --after], "DATETIME", "start date/time", default: "24 hours ago", attribute_name: :after
|
14
15
|
option %w[-b --before], "DATETIME", "end date/time", attribute_name: :before
|
15
16
|
|
17
|
+
begin
|
18
|
+
require "chronic"
|
19
|
+
TimeParser = ::Chronic
|
20
|
+
rescue
|
21
|
+
TimeParser = ::Time
|
22
|
+
end
|
23
|
+
|
16
24
|
protected
|
17
25
|
|
18
26
|
def time_filters
|
@@ -25,11 +33,11 @@ module PagerJudy
|
|
25
33
|
private
|
26
34
|
|
27
35
|
def after=(s)
|
28
|
-
@after =
|
36
|
+
@after = TimeParser.parse(s)
|
29
37
|
end
|
30
38
|
|
31
39
|
def before=(s)
|
32
|
-
@before =
|
40
|
+
@before = TimeParser.parse(s)
|
33
41
|
end
|
34
42
|
|
35
43
|
def default_after
|
data/lib/pager_judy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pager_judy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03
|
11
|
+
date: 2019-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|