mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 22:59:39 +00:00
add playlist sort order toggle, #171
This commit is contained in:
@@ -56,6 +56,7 @@ class Command(BaseCommand):
|
||||
self._mig_channel_tags()
|
||||
self._mig_video_channel_tags()
|
||||
self._mig_fix_download_channel_indexed()
|
||||
self._mig_add_default_playlist_sort()
|
||||
|
||||
def _make_folders(self):
|
||||
"""make expected cache folders"""
|
||||
@@ -389,3 +390,37 @@ class Command(BaseCommand):
|
||||
self.stdout.write(response)
|
||||
sleep(60)
|
||||
raise CommandError(message)
|
||||
|
||||
def _mig_add_default_playlist_sort(self) -> None:
|
||||
"""migrate from 0.5.4 to 0.5.5 set default playlist sortorder"""
|
||||
self.stdout.write("[MIGRATION] set default playlist sort order")
|
||||
path = "ta_playlist/_update_by_query"
|
||||
data = {
|
||||
"query": {
|
||||
"bool": {
|
||||
"must_not": [{"exists": {"field": "playlist_sort_order"}}]
|
||||
}
|
||||
},
|
||||
"script": {
|
||||
"source": "ctx._source.playlist_sort_order = 'top'",
|
||||
"lang": "painless",
|
||||
},
|
||||
}
|
||||
response, status_code = ElasticWrap(path).post(data)
|
||||
if status_code in [200, 201]:
|
||||
updated = response.get("updated")
|
||||
if updated:
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f" ✓ updated {updated} playlists")
|
||||
)
|
||||
else:
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(" no playlists need updating")
|
||||
)
|
||||
return
|
||||
|
||||
message = " 🗙 failed to set default playlist sort order"
|
||||
self.stdout.write(self.style.ERROR(message))
|
||||
self.stdout.write(response)
|
||||
sleep(60)
|
||||
raise CommandError(message)
|
||||
|
||||
Reference in New Issue
Block a user