effective_messaging 0.7.2 → 0.7.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78e95fc092d81efe4f4ff0db0c4d571ec86b7938400dcc7f378963f9e288aeb4
|
4
|
+
data.tar.gz: b206a600a6fc26b75fdba1a26c86754e1ceb66d4be50f0d80b07aa158afec313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85de886b3e80411543f91188ebaa4de3f750a020f61513e81c82f8ef26e5ea8a792cbabd512ef821e13f34374fd30639a1e97d11f1ec00583d952339e8a336b3
|
7
|
+
data.tar.gz: 37f925c590a863999c61bd24008d96423d73a0aa9e2b10d3a914329e07c84589ece96b3aaba013557886d308895fbe544926c9941b951106018384de0197f17c
|
@@ -15,7 +15,13 @@ class EffectiveChatsDatatable < Effective::Datatable
|
|
15
15
|
end
|
16
16
|
|
17
17
|
collection do
|
18
|
-
Effective::Chat.deep.where(id: current_user.chats)
|
18
|
+
chats = Effective::Chat.deep.where(id: current_user.chats)
|
19
|
+
|
20
|
+
if attributes[:year].present?
|
21
|
+
chats = chats.where('created_at >= ?', Time.zone.local(attributes[:year]))
|
22
|
+
end
|
23
|
+
|
24
|
+
chats
|
19
25
|
end
|
20
26
|
|
21
27
|
end
|
@@ -278,16 +278,28 @@ module Effective
|
|
278
278
|
|
279
279
|
report.collection().find_each do |resource|
|
280
280
|
next unless notifiable?(resource) || force
|
281
|
+
|
282
|
+
# Send Now functionality. Don't duplicate if it's same day.
|
283
|
+
next if force && already_notified_today?(resource)
|
284
|
+
|
281
285
|
print('.')
|
282
286
|
|
283
|
-
|
284
|
-
|
287
|
+
begin
|
288
|
+
# For logging
|
289
|
+
assign_attributes(current_resource: resource)
|
285
290
|
|
286
|
-
|
287
|
-
|
288
|
-
Effective::NotificationsMailer.notify_resource(self, resource).deliver_now
|
291
|
+
# Send the resource email
|
292
|
+
Effective::NotificationsMailer.notify_resource(self, resource).deliver_now
|
289
293
|
|
290
|
-
|
294
|
+
# Log that it was sent
|
295
|
+
build_notification_log(resource: resource).save!
|
296
|
+
|
297
|
+
# Count how many we actually sent
|
298
|
+
notified += 1
|
299
|
+
rescue => e
|
300
|
+
EffectiveLogger.error(e.message, associated: self) if defined?(EffectiveLogger)
|
301
|
+
ExceptionNotifier.notify_exception(e, data: { notification_id: id, resource_id: resource.id, resource_type: resource.class.name }) if defined?(ExceptionNotifier)
|
302
|
+
end
|
291
303
|
|
292
304
|
GC.start if (notified % 250) == 0
|
293
305
|
end
|
@@ -299,9 +311,19 @@ module Effective
|
|
299
311
|
notified = 0
|
300
312
|
|
301
313
|
if notifiable_scheduled? || force
|
302
|
-
|
303
|
-
|
304
|
-
|
314
|
+
begin
|
315
|
+
Effective::NotificationsMailer.notify(self).deliver_now
|
316
|
+
|
317
|
+
# Log that it was sent
|
318
|
+
build_notification_log(resource: nil).save!
|
319
|
+
|
320
|
+
# Count how many we actually sent
|
321
|
+
notified += 1
|
322
|
+
rescue => e
|
323
|
+
EffectiveLogger.error(e.message, associated: self) if defined?(EffectiveLogger)
|
324
|
+
ExceptionNotifier.notify_exception(e, data: { notification_id: id }) if defined?(ExceptionNotifier)
|
325
|
+
end
|
326
|
+
|
305
327
|
end
|
306
328
|
|
307
329
|
notified > 0 ? update!(last_notified_at: Time.zone.now, last_notified_count: notified) : touch
|
@@ -324,6 +346,17 @@ module Effective
|
|
324
346
|
notifiable?(resource, date: date)
|
325
347
|
end
|
326
348
|
|
349
|
+
def already_notified_today?(resource)
|
350
|
+
email = resource_email(resource) || resource_user(resource).try(:email)
|
351
|
+
raise("expected an email for #{report} #{report&.id} and #{resource} #{resource&.id}") unless email.present?
|
352
|
+
|
353
|
+
logs = notification_logs.select { |log| log.email == email }
|
354
|
+
return false if logs.count == 0
|
355
|
+
|
356
|
+
# If we already notified today
|
357
|
+
logs.any? { |log| log.created_at&.beginning_of_day == Time.zone.now.beginning_of_day }
|
358
|
+
end
|
359
|
+
|
327
360
|
# Consider the notification logs which track how many and how long ago this notification was sent
|
328
361
|
# It's notifiable? when first time or if it's been immediate_days since last notification
|
329
362
|
def notifiable_immediate?(resource:, date: nil)
|
@@ -1,10 +1,9 @@
|
|
1
1
|
%h2= t('effective_messaging.dashboard')
|
2
2
|
|
3
|
-
-
|
4
|
-
%p You are a #{etd(Effective::ChatUser)} of #{pluralize(current_user.chats.length, etd(Effective::Chat))}.
|
3
|
+
- datatable = EffectiveResources.best('EffectiveChatsDatatable').new(self, namespace: :effective)
|
5
4
|
|
6
|
-
|
5
|
+
- if datatable.present?
|
6
|
+
%p You are a #{etd(Effective::ChatUser)} of #{pluralize(datatable.collection.length, etd(Effective::Chat))}.
|
7
7
|
= render_datatable(datatable, simple: true)
|
8
|
-
|
9
8
|
- else
|
10
9
|
%p You haven't received any #{etsd(Effective::ChatMessage)}. When you do, we'll show it here.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|