mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-07-14 04:58:16 +00:00
fix channel_tabs sync to videos, #build
This commit is contained in:
parent
4245147e7e
commit
faf00bf35e
@ -55,6 +55,7 @@ class Command(BaseCommand):
|
|||||||
self._mig_fix_download_channel_indexed()
|
self._mig_fix_download_channel_indexed()
|
||||||
self._mig_add_default_playlist_sort()
|
self._mig_add_default_playlist_sort()
|
||||||
self._mig_set_channel_tabs()
|
self._mig_set_channel_tabs()
|
||||||
|
self._mig_set_video_channel_tabs()
|
||||||
|
|
||||||
def _make_folders(self):
|
def _make_folders(self):
|
||||||
"""make expected cache folders"""
|
"""make expected cache folders"""
|
||||||
@ -359,3 +360,39 @@ class Command(BaseCommand):
|
|||||||
self.stdout.write(response)
|
self.stdout.write(response)
|
||||||
sleep(60)
|
sleep(60)
|
||||||
raise CommandError(message)
|
raise CommandError(message)
|
||||||
|
|
||||||
|
def _mig_set_video_channel_tabs(self) -> None:
|
||||||
|
"""migrate from 0.5.4 to 0.5.5 set initial video channel tabs"""
|
||||||
|
self.stdout.write("[MIGRATION] set default channel_tabs for videos")
|
||||||
|
|
||||||
|
path = "ta_video/_update_by_query"
|
||||||
|
tabs = VideoTypeEnum.values_known()
|
||||||
|
data = {
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"must_not": [{"exists": {"field": "channel.channel_tabs"}}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"script": {
|
||||||
|
"source": f"ctx._source.channel.channel_tabs = {tabs}",
|
||||||
|
"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} videos")
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.stdout.write(
|
||||||
|
self.style.SUCCESS(" no videos need updating")
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
message = " 🗙 failed to set default channel_tabs"
|
||||||
|
self.stdout.write(self.style.ERROR(message))
|
||||||
|
self.stdout.write(response)
|
||||||
|
sleep(60)
|
||||||
|
raise CommandError(message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user