Refactor app in to its own slice
This commit is contained in:
17
slices/main/repos/top_track_repo.rb
Normal file
17
slices/main/repos/top_track_repo.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module Main
|
||||
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
|
Reference in New Issue
Block a user