78c016ba8df0eeb15ad106e9259b01bbe1f8d0d6
[mygpo.git] / mygpo / search / management / commands / build-search-index.py
blob78c016ba8df0eeb15ad106e9259b01bbe1f8d0d6
1 from django.core.management.base import BaseCommand
2 from optparse import make_option
3 from mygpo.search.models import SearchEntry
4 from mygpo.api.models import ToplistEntry
5 from mygpo.search.util import podcast_entry, podcast_group_entry
7 class Command(BaseCommand):
9 def handle(self, *args, **options):
11 SearchEntry.objects.all().delete()
13 toplist = ToplistEntry.objects.all()
14 for e in toplist:
15 entry = None
16 if e.podcast_group:
17 entry = podcast_group_entry(e.podcast_group, e.subscriptions)
19 elif e.podcast:
20 entry = podcast_entry(e.podcast, e.subscriptions)
22 if entry and entry.text:
23 entry.save()