Move polyfilling artist IDs to scrobble rules
This commit is contained in:
@@ -86,8 +86,6 @@ config :music_library, Oban,
|
|||||||
plugins: [
|
plugins: [
|
||||||
{Oban.Plugins.Cron,
|
{Oban.Plugins.Cron,
|
||||||
crontab: [
|
crontab: [
|
||||||
# every hour
|
|
||||||
{"0 * * * *", MusicLibrary.Worker.PolyfillScrobbledTracks},
|
|
||||||
# every 30 minutes
|
# every 30 minutes
|
||||||
{"*/30 * * * *", MusicLibrary.ScrobbleRules.Worker}
|
{"*/30 * * * *", MusicLibrary.ScrobbleRules.Worker}
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
defmodule MusicLibrary.ScrobbleActivity.Backfill do
|
|
||||||
alias MusicLibrary.Artists
|
|
||||||
alias MusicLibrary.Repo
|
|
||||||
|
|
||||||
@allowed_artists [
|
|
||||||
"Airbag",
|
|
||||||
"Arena",
|
|
||||||
"Dream Theater",
|
|
||||||
"Fish",
|
|
||||||
"Gazpacho",
|
|
||||||
"IQ",
|
|
||||||
"Marillion",
|
|
||||||
"Meer",
|
|
||||||
"Muse",
|
|
||||||
"Opeth",
|
|
||||||
"Pink Floyd",
|
|
||||||
"Porcupine Tree",
|
|
||||||
"Riverside",
|
|
||||||
"Steven Wilson",
|
|
||||||
"Sylvan"
|
|
||||||
]
|
|
||||||
|
|
||||||
def fill_missing_artist_ids do
|
|
||||||
name_id_pairs = Artists.name_id_pairs(@allowed_artists)
|
|
||||||
|
|
||||||
Enum.each(name_id_pairs, fn {name, id} ->
|
|
||||||
Repo.query(
|
|
||||||
"""
|
|
||||||
UPDATE scrobbled_tracks
|
|
||||||
SET artist = json_set(artist, '$.musicbrainz_id', ?)
|
|
||||||
WHERE artist ->> '$.name' == ?;
|
|
||||||
""",
|
|
||||||
[id, name]
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
defmodule MusicLibrary.Worker.PolyfillScrobbledTracks do
|
|
||||||
use Oban.Worker, queue: :heavy_writes, max_attempts: 3
|
|
||||||
|
|
||||||
alias MusicLibrary.ScrobbleActivity.Backfill
|
|
||||||
|
|
||||||
@impl Oban.Worker
|
|
||||||
def perform(%Oban.Job{args: _}) do
|
|
||||||
Backfill.fill_missing_artist_ids()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user