snitch_reporting 1.0.3 → 1.0.4

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: 838bbd8f834c1c4a99d9457021ac12648d020d725fb60b3a28f6072fe7fac847
4
- data.tar.gz: 017ad1b8375de6b1c3b12c5a96e239aa4ec81e44144ea01289bcb995142225f1
3
+ metadata.gz: 13ca38a1a092ebfb990a2dcd85bf75973cf69fee709e2111ad1eb546626d83b6
4
+ data.tar.gz: cda6e441fffb8a0c0691456b3327325ca0d36dd2816f5552cc56aec8bf90256e
5
5
  SHA512:
6
- metadata.gz: d4c27dbc258ac2e021c0812e90150f9e587c72a3082b1790fd38056151bef45a46ca5b600de4312b9b2e91b8dfddfceb612b46ec57856cc9002d1c5fc4ae6a9d
7
- data.tar.gz: 15a25a05a742dbe1d434d4b19e4f8b9d148a1cd83b769e038226dc866432b0fbd41e12063b48cbd83eb6955f49d45e85c73f6697d390176152b4c978926d46b4
6
+ metadata.gz: ece5f42bcd69b1813f8492a5d98f24df398e044d0b2dec2b23667096d93cdc6d742916f99e651659eb0adb559b985b35fb42df6c5e26b226ec4039a3f012c7cb
7
+ data.tar.gz: 77f89fafa5dd29bb2fdbc1e506ed9e03cf3cbb4a39f98fbd2de6b16e84d848db9c2b4158df6dff1074cad8c49856ad237b84029d3c367258686f90171977993e
@@ -74,6 +74,13 @@ todo {
74
74
  white-space: pre;
75
75
  }
76
76
 
77
+ .snitch-tag {
78
+ border-radius: 4px;
79
+ background: $border-grey;
80
+ padding: 3px 5px;
81
+ white-space: nowrap;
82
+ }
83
+
77
84
  .snitch-resolution-switch {
78
85
  -webkit-appearance: none;
79
86
  -moz-appearance: none;
@@ -112,7 +112,7 @@ class ::SnitchReporting::SnitchReportsController < ApplicationController
112
112
  status: {
113
113
  default: :unresolved,
114
114
  values: [:all, :resolved, :unresolved]
115
- },
115
+ }
116
116
  # assignee: {
117
117
  # default: :any,
118
118
  # values: [:any, :me, :not_me, :not_assigned]
@@ -118,6 +118,12 @@ class SnitchReporting::SnitchOccurrence < ApplicationRecord
118
118
  # temp_details
119
119
  # end
120
120
 
121
+ def notify_occurrence
122
+ return unless notify?
123
+
124
+ SnitchReporting.notify(self)
125
+ end
126
+
121
127
  def notify?
122
128
  @should_notify ||= always_notify || report.resolved? || report.occurrence_count == 1
123
129
  end
@@ -125,7 +131,7 @@ class SnitchReporting::SnitchOccurrence < ApplicationRecord
125
131
  private
126
132
 
127
133
  def mark_occurrence
128
- notify? # Store ivar
134
+ notify_occurrence
129
135
  report_updates = { last_occurrence_at: Time.current, resolved_at: nil }
130
136
  report_updates[:first_occurrence_at] = Time.current if report.first_occurrence_at.nil?
131
137
  report_updates[:occurrence_count] = report.occurrence_count.to_i + 1
@@ -24,6 +24,8 @@ class SnitchReporting::SnitchReport < ApplicationRecord
24
24
  # belongs_to :resolved_by
25
25
  # belongs_to :ignored_by
26
26
 
27
+ serialize :tags, ::SnitchReporting::Service::JSONWrapper
28
+
27
29
  scope :resolved, -> { where.not(resolved_at: nil) }
28
30
  scope :unresolved, -> { where(resolved_at: nil) }
29
31
  scope :ignored, -> { where.not(ignored_at: nil) }
@@ -199,7 +201,9 @@ class SnitchReporting::SnitchReport < ApplicationRecord
199
201
  # Not using find or create because the slug might be `nil`- in these
200
202
  # cases, we want to create a new report so that we don't falsely group
201
203
  # unrelated errors together.
202
- report || create(report_identifiable_data)
204
+ report ||= create(report_identifiable_data)
205
+ report.add_tags(arg_hash.delete(:tags))
206
+ report
203
207
  end
204
208
 
205
209
  def gather_report_data(env, exceptions, arg_hash, arg_values)
@@ -262,6 +266,20 @@ class SnitchReporting::SnitchReport < ApplicationRecord
262
266
  trackers.tracker_for_date(date)
263
267
  end
264
268
 
269
+ def tags
270
+ super || []
271
+ end
272
+
273
+ def tags=(new_tags)
274
+ super((new_tags.try(:to_a) || [new_tags]).compact.flatten)
275
+ end
276
+
277
+ def add_tags(new_tags)
278
+ return if new_tags.blank?
279
+
280
+ update(tags: tags + [new_tags])
281
+ end
282
+
265
283
  def resolved?; resolved_at?; end
266
284
  def ignored?; ignored_at?; end
267
285
 
@@ -1,13 +1,9 @@
1
1
  <div class="snitch-reporting">
2
- <!-- <div class="snitch-nav">
2
+ <!--
3
3
  <div class="nav-tab">
4
4
  <input type="search" name="search" value="<%= params[:search] %>" placeholder="Search">
5
5
  </div>
6
- <a href="<%# %>">Status</a>
7
- <a href="<%# %>">Assignee</a>
8
- <a href="<%# %>">Occurred</a>
9
- <a href="<%# %>">Ignored</a>
10
- </div> -->
6
+ -->
11
7
  <div class="filters">
12
8
  <% @filter_sets.each do |filter_name, filter_set| %>
13
9
  <div class="snitch-table filter-table">
@@ -44,7 +40,7 @@
44
40
  <div class="snitch-th">Error</div>
45
41
  <div class="snitch-th" style="width: 150px;">Last</div>
46
42
  <div class="snitch-th" style="width: 1px;">Times</div>
47
- <div class="snitch-th" style="width: 1px;">Assigned</div>
43
+ <div class="snitch-th" style="width: 1px;">Tags</div>
48
44
  <div class="snitch-th" style="width: 1px;">Status</div>
49
45
  </div>
50
46
  </div>
@@ -62,7 +58,12 @@
62
58
  <% end %>
63
59
  <div class="snitch-td"><%= report.last_occurrence_at %></div>
64
60
  <div class="snitch-td"><%= number_with_delimiter(report.occurrence_count) %></div>
65
- <div class="snitch-td"><%= report.assigned_to.try(:name).presence || "-" %></div>
61
+ <div class="snitch-td">
62
+ <% report.tags.each_with_index do |tag, idx| %>
63
+ <span class="snitch-tag"><%= tag %></span><%= ', ' if idx < report.tags.length - 1 %>
64
+ <% end %>
65
+ </div>
66
+ <!-- <div class="snitch-td"><%= report.assigned_to.try(:name).presence || "-" %></div> -->
66
67
  <div class="snitch-td">
67
68
  <%= content_tag :input, "", type: :checkbox, name: :resolved, class: "snitch-resolution-switch", checked: report.resolved?, data: { mark_resolution_url: snitch_report_url(report) } %>
68
69
  </div>
@@ -91,10 +91,14 @@
91
91
  </todo>
92
92
  </div>
93
93
  </div> -->
94
- <!-- <div class="snitch-tr">
95
- <div class="snitch-td">Tags <todo>(edit)</todo></div>
96
- <div class="snitch-td"><%= @report.tags %></div>
97
- </div> -->
94
+ <div class="snitch-tr">
95
+ <div class="snitch-td">Tags</div>
96
+ <div class="snitch-td">
97
+ <% @report.tags.each_with_index do |tag, idx| %>
98
+ <span class="snitch-tag"><%= tag %></span><%= ', ' if idx < @report.tags.length - 1 %>
99
+ <% end %>
100
+ </div>
101
+ </div>
98
102
  </div>
99
103
  </div>
100
104
 
@@ -0,0 +1,5 @@
1
+ ::SnitchReporting::SnitchReport.log_levels.symbolize_keys.keys.each do |log_level|
2
+ ::SnitchReporting.define_singleton_method(log_level) do |*args|
3
+ ::SnitchReporting::SnitchReport.report(log_level, args)
4
+ end
5
+ end
@@ -4,7 +4,12 @@ class SnitchReporting::Rack
4
4
 
5
5
  def initialize(app, notify_callback=nil)
6
6
  @app = app
7
- @notify_callback = notify_callback
7
+
8
+ return unless notify_callback.present?
9
+
10
+ ::SnitchReporting.define_singleton_method :notify do |occurrence|
11
+ notify_callback.call(occurrence)
12
+ end
8
13
  end
9
14
 
10
15
  def call(env)
@@ -20,7 +25,6 @@ class SnitchReporting::Rack
20
25
  response
21
26
  rescue Exception => exception
22
27
  occurrence = ::SnitchReporting::SnitchReport.fatal(exception, env: env)
23
- notify_callback.call(occurrence) if occurrence.notify?
24
28
 
25
29
  raise exception unless exception.is_a?(SnitchException)
26
30
 
@@ -1,3 +1,3 @@
1
1
  module SnitchReporting
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snitch_reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocco Nicholls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -102,6 +102,7 @@ files:
102
102
  - app/views/snitch_reporting/snitch_reports/edit.html.erb
103
103
  - app/views/snitch_reporting/snitch_reports/index.html.erb
104
104
  - app/views/snitch_reporting/snitch_reports/show.html.erb
105
+ - config/initializers/snitch_reporting.rb
105
106
  - config/routes.rb
106
107
  - lib/generators/snitch_reporting/install/install_generator.rb
107
108
  - lib/generators/snitch_reporting/install/templates/install_snitch_reporting.rb