notifiable-core 0.2.2 → 0.2.3

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: 98c5713043730258b62c23e08942daba07ec2d600373c65d64494f6fd34d9a01
4
- data.tar.gz: 33bdabb3ed2d2a8dbf0fb61dbb5eaa0eeb83972f22ba1f3f31b666afbd3739b8
3
+ metadata.gz: 9056aaabe8cf5a4320058e83b7653887d248d7bbe16d6e27615d448d11c0096e
4
+ data.tar.gz: cb16692c30b41e7ca0be966167b9d6dee075418d410b647ea1efc60392df9f65
5
5
  SHA512:
6
- metadata.gz: 8ca200e50537f583ebadb0145431254eb4fa071fa3874371f963a67251661234dbb64ab7c76e75cf36d497b3c29a577803ef1d7395138117fd65082aeaf1e21c
7
- data.tar.gz: 89d927957447f6de3d02bb0fed70768f589295836785aee0b40d57f382d13a0eff662b7cb7d47a4c5cab042252e93b811d94adad401eec2749adeb7d767bd2cf
6
+ metadata.gz: 883ec9596867c2b14479a49bf35770252364d924477ecedb90215df434c856b2ff4f393feb648d5d65198cc2555f30749cb707986da0df602c5ea72e9bd3322b
7
+ data.tar.gz: 8f73f02e2e78e8bb769c7ce17e6d899f7c305d62775124a8e49b72e924fb5412c025f4d1e6b7aafa212ddcbc94f045bb2ee88ae4f88148f4c54da812e14ce635
@@ -17,6 +17,7 @@ module Notifiable
17
17
 
18
18
  def initialize(notification)
19
19
  @notification = notification
20
+ @mutex = Mutex.new
20
21
  end
21
22
 
22
23
  def send_notification(device_token)
@@ -42,14 +43,16 @@ module Notifiable
42
43
  def flush; end
43
44
 
44
45
  def processed(device_token, status = NotificationStatus::SENT_STATUS, error_code = nil, error_message = nil)
45
- if @notification.app.save_notification_statuses
46
- receipts << { notification_id: notification.id, device_token_id: device_token.id, status: status, created_at: DateTime.now, error_code: error_code, error_message: error_message }
47
- save_receipts if receipts.count >= Notifiable.notification_status_batch_size
48
- end
46
+ @mutex.synchronize {
47
+ if @notification.app.save_notification_statuses
48
+ receipts << { notification_id: notification.id, device_token_id: device_token.id, status: status, created_at: DateTime.now, error_code: error_code, error_message: error_message }
49
+ save_receipts if receipts.count >= Notifiable.notification_status_batch_size
50
+ end
49
51
 
50
- @notification.sent_count += 1
51
- @notification.gateway_accepted_count += 1 if status == NotificationStatus::SENT_STATUS
52
- @notification.save if @notification.sent_count % Notifiable.notification_status_batch_size == 0
52
+ @notification.increment(:sent_count)
53
+ @notification.increment(:gateway_accepted_count) if status == NotificationStatus::SENT_STATUS
54
+ @notification.save if @notification.sent_count % Notifiable.notification_status_batch_size == 0
55
+ }
53
56
  end
54
57
 
55
58
  private
@@ -1,3 +1,3 @@
1
1
  module Notifiable
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-07 00:00:00.000000000 Z
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord