unread-mongoid 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: adc69505c8208e251baa393dbf71f86609691942
4
- data.tar.gz: 07e4fff7bf3a8ea8757a1e2ea96d37dddc540ec4
3
+ metadata.gz: 73628836e4b9aae3f277c0abb96fb08380ade7e3
4
+ data.tar.gz: 8b56c1aa01a36875938c2e61563cee7037953c23
5
5
  SHA512:
6
- metadata.gz: 18ac058f67de7193ece5002d70a923a96ddfe45a21f33b817c5835f60fd83f34d3a56c3e3f730768e3571e0109f0edfea73e7f969489b27fb88f71b1e65b2eb2
7
- data.tar.gz: 29c248a3de7261a8de7a5b23564206cab8cc12c4bb574ccc5a2693097668f8d3bc782319dfdcad921d8f9c691db0a2f9bdd4c6d4b0ce167f60fe2c7a5be053ac
6
+ metadata.gz: f90ae7bf77874d440e4db15a0485614cfde868dc33b825e0fa9299a80f81778a1bce374ca5b29021ff70f96e3bb63ef3e78348e874b44396bcb1cff48a394477
7
+ data.tar.gz: 44da093c2921aa02aee69303dfe4dd37fba6f9c58a348c67b1c4ffe0afa8d1fb047060327c3bc7534c04fd2e5c4b5a534fcc0170b7d34e7182ce2ab07bfee644
@@ -28,14 +28,6 @@ module UnreadMongoid
28
28
 
29
29
  has_many :read_marks, :as => :readable, :dependent => :destroy
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
-
39
31
  ReadMark.readable_classes ||= []
40
32
  ReadMark.readable_classes << self unless ReadMark.readable_classes.include?(self)
41
33
 
@@ -2,7 +2,6 @@ class ReadMark
2
2
  include Mongoid::Document
3
3
 
4
4
  field :timestamp, type: Time
5
- field :readable_timestamp, type: Time, default: -> { readable.readable_timestamp if readable }
6
5
 
7
6
  belongs_to :readable, :polymorphic => true
8
7
  belongs_to :user
@@ -94,10 +94,6 @@ module UnreadMongoid
94
94
  end
95
95
 
96
96
  module InstanceMethods
97
- def readable_timestamp
98
- self.send(readable_options[:on]).to_s(:db)
99
- end
100
-
101
97
  def unread?(user)
102
98
  self.class.unread_by(user).and(_id: self._id).exists?
103
99
  end
@@ -37,12 +37,9 @@ module UnreadMongoid
37
37
  end
38
38
 
39
39
  def specifically_marked_ids(user)
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)
40
+ read_marks_query(user).ne(readable_id: nil).select do |read_mark|
41
+ read_mark.timestamp >= read_mark.readable.send(self.readable_options[:on])
42
+ end.map(&:readable_id)
46
43
  end
47
44
  end
48
45
  end
@@ -1,3 +1,3 @@
1
1
  module UnreadMongoid
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  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, readable_timestamp: Time.now - 1.days
160
+ other_read_mark = @reader.read_marks.create! :readable_type => 'Foo', :readable_id => 42, :timestamp => 5.years.ago
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.3
4
+ version: 0.0.4
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: 2014-01-17 00:00:00.000000000 Z
12
+ date: 2014-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -103,7 +103,4 @@ rubygems_version: 2.0.2
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Manages read/unread status of Mongoid objects
106
- test_files:
107
- - test/mongoid.yml
108
- - test/test_helper.rb
109
- - test/unread_test.rb
106
+ test_files: []