-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display a tag cloud with tags assigned to videos
+ Store tag list in CACHE + add a reindex_videos script to recreate ES video index
- Loading branch information
Showing
11 changed files
with
174 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""Script reindexing all videos (useful in case of loss of the ElasticSearch database)""" | ||
|
||
from django.core.management.base import BaseCommand | ||
from pod.video.models import Video | ||
from pod.video_search.models import index_video | ||
|
||
|
||
def reindex_all_videos(dry_run: bool) -> int: | ||
"""Reindex all videos.""" | ||
print("\nReindexing all videos...") | ||
videos = Video.objects.all() | ||
nb_videos = 0 | ||
for vid in videos: | ||
print(".", end="") | ||
if not dry_run: | ||
index_video(vid) | ||
nb_videos += 1 | ||
print("") | ||
return nb_videos | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Reindex all videos.""" | ||
|
||
help = "Reindex all videos (useful in case of loss of the ElasticSearch database)" | ||
|
||
def add_arguments(self, parser) -> None: | ||
"""Allow arguments to be used with the command.""" | ||
parser.add_argument( | ||
"--dry", | ||
help="Simulate what would be reindexed.", | ||
action="store_true", | ||
default=False, | ||
) | ||
|
||
def handle(self, *args, **options) -> None: | ||
"""Handle the clean_video_files command call.""" | ||
if options["dry"]: | ||
print("Simulation mode ('dry'). Nothing will be deleted.") | ||
self.nb_reindexed = reindex_all_videos(options["dry"]) | ||
|
||
self.print_resume(options["dry"]) | ||
|
||
def print_resume(self, dry_run: bool) -> None: | ||
"""Print summary of reindexed objects.""" | ||
|
||
if dry_run: | ||
print( | ||
"[DRY RUN] %i video(s) would have been reindexed." | ||
% (self.nb_reindexed) | ||
) | ||
else: | ||
print("%i video(s) reindexed." % self.nb_reindexed) | ||
print("Have a nice day ;)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.