Add maintenance tasks to refresh all artist wikipedia bios

This commit is contained in:
Claudio Ortolina
2026-02-09 15:24:29 +00:00
parent bcae291cff
commit 25bd4b10c4
5 changed files with 51 additions and 0 deletions
+6
View File
@@ -19,6 +19,12 @@ defmodule MusicLibrary.Artists.Batch do
end)
end
def refresh_wikipedia_data do
run_on_all_artist_infos(fn artist_info ->
Artists.refresh_wikipedia_data_async(artist_info)
end)
end
defp run_on_all_artist_infos(fun) do
q = from(r in ArtistInfo)
stream = Repo.stream(q, max_rows: 50)
@@ -50,6 +50,10 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
:refresh_artists_discogs_jobs,
count_jobs("MusicLibrary.Worker.ArtistRefreshDiscogsData")
)
|> assign(
:refresh_artists_wikipedia_jobs,
count_jobs("MusicLibrary.Worker.ArtistRefreshWikipediaData")
)
end
defp count_jobs(worker) do
@@ -94,6 +98,14 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
|> put_toast(:info, gettext("Operation started in the background."))}
end
def handle_event("refresh_artists_wikipedia_data", _params, socket) do
Artists.Batch.refresh_wikipedia_data()
{:noreply,
socket
|> put_toast(:info, gettext("Operation started in the background."))}
end
def handle_event("db_vacuum", _params, socket) do
case Repo.vacuum() do
{:ok, _result} ->
@@ -80,6 +80,19 @@
<.loading :if={@refresh_artists_discogs_jobs > 0} class="size-4" />
{gettext("Refresh Discogs data")}
</.button>
<.button
type="button"
phx-click="refresh_artists_wikipedia_data"
disabled={@refresh_artists_wikipedia_jobs > 0}
data-confirm={
gettext(
"Are you sure you want to refresh Wikipedia data for all artists? This operation can take a long time to complete."
)
}
>
<.loading :if={@refresh_artists_wikipedia_jobs > 0} class="size-4" />
{gettext("Refresh Wikipedia data")}
</.button>
</.button_group>
</li>
</ul>
+10
View File
@@ -1867,3 +1867,13 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Wikipedia data refreshed successfully"
msgstr ""
#: lib/music_library_web/live/maintenance_live/index.html.heex
#, elixir-autogen, elixir-format
msgid "Are you sure you want to refresh Wikipedia data for all artists? This operation can take a long time to complete."
msgstr ""
#: lib/music_library_web/live/maintenance_live/index.html.heex
#, elixir-autogen, elixir-format
msgid "Refresh Wikipedia data"
msgstr ""
+10
View File
@@ -1867,3 +1867,13 @@ msgstr ""
#, elixir-autogen, elixir-format, fuzzy
msgid "Wikipedia data refreshed successfully"
msgstr ""
#: lib/music_library_web/live/maintenance_live/index.html.heex
#, elixir-autogen, elixir-format, fuzzy
msgid "Are you sure you want to refresh Wikipedia data for all artists? This operation can take a long time to complete."
msgstr ""
#: lib/music_library_web/live/maintenance_live/index.html.heex
#, elixir-autogen, elixir-format, fuzzy
msgid "Refresh Wikipedia data"
msgstr ""