Add maintenance tasks to refresh all artist wikipedia bios
This commit is contained in:
@@ -19,6 +19,12 @@ defmodule MusicLibrary.Artists.Batch do
|
|||||||
end)
|
end)
|
||||||
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
|
defp run_on_all_artist_infos(fun) do
|
||||||
q = from(r in ArtistInfo)
|
q = from(r in ArtistInfo)
|
||||||
stream = Repo.stream(q, max_rows: 50)
|
stream = Repo.stream(q, max_rows: 50)
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
|
|||||||
:refresh_artists_discogs_jobs,
|
:refresh_artists_discogs_jobs,
|
||||||
count_jobs("MusicLibrary.Worker.ArtistRefreshDiscogsData")
|
count_jobs("MusicLibrary.Worker.ArtistRefreshDiscogsData")
|
||||||
)
|
)
|
||||||
|
|> assign(
|
||||||
|
:refresh_artists_wikipedia_jobs,
|
||||||
|
count_jobs("MusicLibrary.Worker.ArtistRefreshWikipediaData")
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp count_jobs(worker) do
|
defp count_jobs(worker) do
|
||||||
@@ -94,6 +98,14 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
|
|||||||
|> put_toast(:info, gettext("Operation started in the background."))}
|
|> put_toast(:info, gettext("Operation started in the background."))}
|
||||||
end
|
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
|
def handle_event("db_vacuum", _params, socket) do
|
||||||
case Repo.vacuum() do
|
case Repo.vacuum() do
|
||||||
{:ok, _result} ->
|
{:ok, _result} ->
|
||||||
|
|||||||
@@ -80,6 +80,19 @@
|
|||||||
<.loading :if={@refresh_artists_discogs_jobs > 0} class="size-4" />
|
<.loading :if={@refresh_artists_discogs_jobs > 0} class="size-4" />
|
||||||
{gettext("Refresh Discogs data")}
|
{gettext("Refresh Discogs data")}
|
||||||
</.button>
|
</.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>
|
</.button_group>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1867,3 +1867,13 @@ msgstr ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Wikipedia data refreshed successfully"
|
msgid "Wikipedia data refreshed successfully"
|
||||||
msgstr ""
|
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 ""
|
||||||
|
|||||||
@@ -1867,3 +1867,13 @@ msgstr ""
|
|||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "Wikipedia data refreshed successfully"
|
msgid "Wikipedia data refreshed successfully"
|
||||||
msgstr ""
|
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 ""
|
||||||
|
|||||||
Reference in New Issue
Block a user