Make bookmark reminders a bit smarter
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
require "time_math"
|
||||
|
||||
module Adamantium
|
||||
module Repos
|
||||
class PostRepo < Adamantium::Repo[:posts]
|
||||
def for_reminders(limit:)
|
||||
def recent(limit:)
|
||||
date = Time.now
|
||||
|
||||
posts
|
||||
.where(post_type: "bookmark", is_read: false)
|
||||
.where(post_type: "bookmark", is_read: false, published_at: TimeMath.day.advance(date, -7)...TimeMath.day.floor(date))
|
||||
.limit(limit)
|
||||
.published
|
||||
.combine(:tags)
|
||||
.order(Sequel.desc(:published_at))
|
||||
.to_a
|
||||
end
|
||||
|
||||
def random(limit:, excluding:)
|
||||
posts
|
||||
.where(post_type: "bookmark", is_read: false)
|
||||
.exclude(id: excluding)
|
||||
.limit(limit)
|
||||
.published
|
||||
.order(Sequel.lit("random()"))
|
||||
.to_a
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user