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

Utilizing current time instead of matching reference timestamp field #100

Open
etcook opened this issue Apr 17, 2018 · 6 comments
Open

Utilizing current time instead of matching reference timestamp field #100

etcook opened this issue Apr 17, 2018 · 6 comments

Comments

@etcook
Copy link

etcook commented Apr 17, 2018

What's the argument for utilizing matching the timestamp of the read_mark with the reference timestamp field? Why not just set the current time?

I was in the middle of building a derivative read report by left joining the data, and was surprised to see the timestamp field matched every single created_at. My intention was to build an "aging" report that showed how long it took to read an object.

Based on your response, if you'd like, I'll submit a PR to set it to current time instead.

@ledermann
Copy link
Owner

Thanks for your feedback, but I don't see what's wrong with the timestamps. The single timestamp (read_marks.readable_type IS NOT NULL) is the time when the readable was read by the user. The global timestamp (read_marks.readable_type IS NULL) is the time where the latest mark_as_read! :all, for: @reader was made.

What kind of improvement do you see?

@etcook
Copy link
Author

etcook commented Apr 17, 2018

That's the behavior I expected, but I don't think that's what it's doing. All of my read_marks have the exact same time as created_at (which I'm using as a reference).

rm.timestamp = self.send(readable_options[:on])

@ledermann
Copy link
Owner

ledermann commented Apr 17, 2018

You are right, not the reading time is stored, it's the reference time of the readable. Sorry - it's five year old code :)

Using the current time feels better for me. But beware, the GarbageCollector has to be changed/rewritten for this. This line needs the current implementation:
https://github.com/ledermann/unread/blob/v0.10.1/lib/unread/garbage_collector.rb#L44

Nevertheless, I'm open for a PR.

@ledermann
Copy link
Owner

Two notes about your "aging report":

  • In the database there is no difference between "the user as read the individual readable" and "the user has not read it, but has marked multiple items as read in one step".
  • After the garbage collection, old read_marks are deleted and therefore the time of reading is lost.

@etcook
Copy link
Author

etcook commented Apr 18, 2018

@ledermann Thank you for the quick response (and the gem). Luckily in this circumstance, I'm neither calling garbage collection nor letting them read multiple items / mark all read. I'll take a look at the gc code and submit a pr in a few. Thanks!

@deikka
Copy link

deikka commented Nov 11, 2019

Hi! I assume that the PR never existed, right? Any tips on what to change in the gem to get the read time instead the created_at timestamp?

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

3 participants