Cache top tracks

This commit is contained in:
2023-06-12 16:48:37 +10:00
parent a50018f712
commit e075e6e3ef
7 changed files with 62 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
module Adamantium
module Repos
class TopTrackRepo < Adamantium::Repo[:top_tracks]
def for_post(id:)
top_tracks
.where(post_id: id)
.to_a
end
def upsert(post_id:, name:, artist:, url:, mb_id:)
top_tracks
.upsert({name: name, artist: artist, url: url, mb_id: mb_id, post_id: post_id},
{ target: :post_id, update: {name: name, artist: artist, url: url, mb_id: mb_id, post_id: post_id} })
end
end
end
end