unread-mongoid 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/changelog.md +4 -0
- data/lib/unread_mongoid/base.rb +8 -0
- data/lib/unread_mongoid/read_mark.rb +1 -0
- data/lib/unread_mongoid/readable.rb +4 -0
- data/lib/unread_mongoid/scopes.rb +6 -1
- data/lib/unread_mongoid/version.rb +1 -1
- data/test/unread_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fff81cda9ab35182ca6e221415467c3b36df486d
|
4
|
+
data.tar.gz: 58fbf8f25b5b3c06c858c0e68017b1ad8a50e202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9528baf77bf362f20bf016193cd8ccf631fac799c2984353c400cff8e478b5aefb0983659d32f1cc69a55fbbaf6cdbe7496d69e2f01abd6abd91a118e0436e
|
7
|
+
data.tar.gz: 6a69cc802404a2b5b4708046de7bd074903e2fe0d2258c11339ab312b68d01a2c9790eaec163f823d8f77c3d514f768c33b5b8585914e7e01164abfc3e4a931b
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Unread-Mongoid
|
|
4
4
|
Ruby gem to manage read/unread status of Mongoid objects.
|
5
5
|
|
6
6
|
## Credit
|
7
|
-
First and foremost this is a fork of [Unread](https://github.com/ledermann/unread) by [Georg Ledermann](http://www.georg-ledermann.de). If you don't have to use Mongo for this I highly reccoment you use his gem, this is a task much better suited to a relational db
|
7
|
+
First and foremost this is a fork of [Unread](https://github.com/ledermann/unread) by [Georg Ledermann](http://www.georg-ledermann.de). If you don't have to use Mongo for this I highly reccoment you use his gem, this is a task much better suited to a relational db.
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
data/changelog.md
CHANGED
data/lib/unread_mongoid/base.rb
CHANGED
@@ -28,6 +28,14 @@ module UnreadMongoid
|
|
28
28
|
|
29
29
|
has_many :read_marks, :as => :readable, :dependent => :delete_all
|
30
30
|
|
31
|
+
# :(
|
32
|
+
after_save do |doc|
|
33
|
+
doc.read_marks.each do |mark|
|
34
|
+
mark.readable_timestamp = doc.readable_timestamp
|
35
|
+
mark.save!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
31
39
|
ReadMark.readable_classes ||= []
|
32
40
|
ReadMark.readable_classes << self unless ReadMark.readable_classes.include?(self)
|
33
41
|
|
@@ -37,7 +37,12 @@ module UnreadMongoid
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def specifically_marked_ids(user)
|
40
|
-
|
40
|
+
time_comparison = "this.timestamp >= this.readable_timestamp"
|
41
|
+
|
42
|
+
read_marks_query(user).ne(readable_id: nil)
|
43
|
+
.for_js(time_comparison)
|
44
|
+
.only(:readable_id)
|
45
|
+
.map(&:readable_id)
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
data/test/unread_test.rb
CHANGED
@@ -157,7 +157,7 @@ class UnreadTest < ActiveSupport::TestCase
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def test_cleanup_read_marks_not_delete_from_other_readables
|
160
|
-
other_read_mark = @reader.read_marks.create! :readable_type => 'Foo', :readable_id => 42, :timestamp => 5.years.ago
|
160
|
+
other_read_mark = @reader.read_marks.create! :readable_type => 'Foo', :readable_id => 42, :timestamp => 5.years.ago, readable_timestamp: Time.now - 1.days
|
161
161
|
Email.cleanup_read_marks!
|
162
162
|
assert_equal true, ReadMark.where(_id: other_read_mark._id).exists?
|
163
163
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unread-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hunter Haydel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|