notifications 0.6.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c4cb0d88943eedf45ead745235a72a06b5ec3762fd1d1d30b1c7b0ea12f2ad8
4
- data.tar.gz: 970edb7122c6a3b8a1c6d057b10c5092f1ae7a5cb0b059590567205230717768
3
+ metadata.gz: 9cf008411221f8643f6272a4f492d6567f7e4c2e0391ee64aab731a3895c7e74
4
+ data.tar.gz: 75455d8f4aafd04a1d2ec0b57fd4e50e61518b54a8e27667d8e694be5210747d
5
5
  SHA512:
6
- metadata.gz: c5988152884954fc797937c1236eba2c44b34878f722e25617232f9d61d37be3a1c1781a4624de77da8ff3c0cc371a0f07336931fb7ac2de682ff5e6d775d7da
7
- data.tar.gz: c0cbe1c39d35c83a38c721a6bd96cf77aa93a1c4b97f5d75c43418aa91b85f242b527d604e1198b5a62349a6a4a341bc5f25dae3b1ffb21ce0aac2636f13d601
6
+ metadata.gz: 1dbee55f530440d4c1ed3000857ffdc4abcbb25825c06164b658fa67b7f19e29a872fc851cfa64b7477db7da491a4f25ab6e5cda6bf461942251220f7c1c687b
7
+ data.tar.gz: 1feea3486d23c7e3e6598cdf012cd7f947cc017189b2258503c07236b8d1f71854cff20645d0e9df94bd6c548df8b6d4955d7e012407baba3eeafb6c6a842f7e
data/README.md CHANGED
@@ -61,7 +61,43 @@ end
61
61
  Get unread notifications count for a user:
62
62
 
63
63
  ```rb
64
- count = Notification.unread_count(current_user)
64
+ # unread count
65
+ unread_count = Notification.unread_count(current_user)
66
+
67
+ # read count
68
+ read_count = Notification.read_count(current_user)
69
+
70
+ ```
71
+
72
+ ```rb initialize/**.rb
73
+ # for non-user class
74
+ Notifications.config.user_class = 'Member'
75
+
76
+ #or change
77
+
78
+ Notifications.configure do
79
+ # Class name of you User model, default: 'User'
80
+ self.user_class = 'User'
81
+
82
+ # Method of user name in User model, default: 'name'
83
+ # self.user_name_method = 'name'
84
+
85
+ # Method of user avatar in User model, default: nil
86
+ # self.user_avatar_url_method = nil
87
+
88
+ # Method name of user profile page path, in User model, default: nil
89
+ # self.user_profile_url_method = 'profile_url'
90
+
91
+ # authenticate_user method in your Controller, default: nil
92
+ # If you use Devise, authenticate_user! is correct
93
+ # self.authenticate_user_method = 'authenticate_user!'
94
+
95
+ # current_user method name in your Controller, default: 'current_user'
96
+ # If you use Devise, current_user is correct
97
+ # self.current_user_method = 'current_user'
98
+ end
99
+
100
+
65
101
  ```
66
102
 
67
103
  ### Write your custom Notification partial view for notify_types:
@@ -1,15 +1,17 @@
1
- class CreateNotifications < ActiveRecord::Migration[5.0]
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNotifications < ActiveRecord::Migration[5.2]
2
4
  def change
3
5
  create_table :notifications do |t|
4
- t.integer :user_id, null: false
5
- t.integer :actor_id
6
+ t.bigint :user_id, null: false
7
+ t.bigint :actor_id
6
8
  t.string :notify_type, null: false
7
9
  t.string :target_type
8
- t.integer :target_id
10
+ t.bigint :target_id
9
11
  t.string :second_target_type
10
- t.integer :second_target_id
12
+ t.bigint :second_target_id
11
13
  t.string :third_target_type
12
- t.integer :third_target_id
14
+ t.bigint :third_target_id
13
15
  t.datetime :read_at
14
16
 
15
17
  t.timestamps null: false
@@ -13,6 +13,8 @@ module Notifications
13
13
  belongs_to :third_target, polymorphic: true, optional: true
14
14
 
15
15
  scope :unread, -> { where(read_at: nil) }
16
+ scope :read, -> { where.not(read_at: nil) }
17
+
16
18
  end
17
19
 
18
20
  def read?
@@ -45,6 +47,10 @@ module Notifications
45
47
  def unread_count(user)
46
48
  Notification.where(user: user).unread.count
47
49
  end
50
+
51
+ def read_count(user)
52
+ Notification.where(user: user).read.count
53
+ end
48
54
  end
49
55
  end
50
56
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifications
2
- VERSION = '0.6.1'
4
+ VERSION = '1.0.0'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kaminari
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5'
33
+ version: '5.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5'
40
+ version: '5.2'
41
41
  description: Rails mountable Notification for any applications.
42
42
  email:
43
43
  - huacnlee@gmail.com
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.0.1
91
+ rubygems_version: 3.0.3
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Rails mountable Notification for any applications.