Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.unread? return unexpected value #74

Open
wootaw opened this issue Apr 24, 2016 · 3 comments
Open

.unread? return unexpected value #74

wootaw opened this issue Apr 24, 2016 · 3 comments

Comments

@wootaw
Copy link

wootaw commented Apr 24, 2016

If exist class:

class A
end

class B < A
  acts_as_readable :on => :created_at
end

Then use it like here:

b = B.create!
b.mark_as_read! for => user

b.unread?(user) # It will return a unexpected result
@ledermann
Copy link
Owner

What do you mean with "unexpected"?

BTW: Your change breaks the tests.

@wootaw
Copy link
Author

wootaw commented Apr 24, 2016

b.unread?(user) # Should be false, But return true

After call mark_as_read!,

<ReadMark id: 1, readable_id: 1, reader_id: 1, readable_type: "A", timestamp: nil, reader_type: "User">

This record has been created in the db, But call b.unread?(user), the sql:

SELECT 1 AS one FROM "bs" LEFT JOIN "read_marks"
 ON "read_marks".readable_type = 'B'
 AND "read_marks".readable_id = "bs"."id"
 AND "read_marks".reader_id = 1
 AND "read_marks".reader_type = 'User'
 AND "read_marks".timestamp >= "bs"."created_at" WHERE ("read_marks".id IS NULL
 AND "bs"."created_at" > '2016-04-24 05:35:16.989270') AND "bs"."id" = 1 LIMIT 1

@ledermann
Copy link
Owner

@tangopium: This issue belongs to code from #68. Do you have an idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants