From c27ad28697854c3b61d362456ed83f9a81bf9189 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Fri, 23 Feb 2024 08:31:30 +1100 Subject: [PATCH] Add mising repos post-refactor --- app/repos/podcast_scrobble_repo.rb | 26 ++++++++++++++++++++++++++ app/repos/post_repo.rb | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 app/repos/podcast_scrobble_repo.rb create mode 100644 app/repos/post_repo.rb diff --git a/app/repos/podcast_scrobble_repo.rb b/app/repos/podcast_scrobble_repo.rb new file mode 100644 index 0000000..08d93e0 --- /dev/null +++ b/app/repos/podcast_scrobble_repo.rb @@ -0,0 +1,26 @@ +module Adamantium + module Repos + class PodcastScrobbleRepo < Adamantium::Repo[:podcast_scrobbles] + commands :create + + def exists?(id:) + !!podcast_scrobbles + .where(overcast_id: id) + .one + end + + def listing + podcast_scrobbles + .order(Sequel.desc(:listened_at)) + .limit(5) + .to_a + end + + def for_timemachine(date:) + podcast_scrobbles + .where(listened_at: TimeMath.day.floor(date)...TimeMath.day.advance(date, +1)) + .to_a + end + end + end +end diff --git a/app/repos/post_repo.rb b/app/repos/post_repo.rb new file mode 100644 index 0000000..be560c4 --- /dev/null +++ b/app/repos/post_repo.rb @@ -0,0 +1,19 @@ +module Adamantium + module Repos + class PostRepo < Adamantium::Repo[:posts] + Sequel.extension :pg_json + Sequel.extension :pg_json_ops + + def for_reminders(limit:) + posts + .where(post_type: "bookmark", is_read: false) + .limit(limit) + .published + .combine(:tags) + .order(Sequel.desc(:published_at)) + .to_a + end + + end + end +end