(run_every=UPDATE_INTERVAL)
Schedules podcast updates that are due within ``interval``
Schedules podcast updates that are due within ``interval``
Schedules podcast updates that are due within interval
def update_search_index(run_every=UPDATE_INTERVAL):
    """Schedules podcast updates that are due within ``interval``"""

    logger.info("Updating search index")

    # We avoid an UPDATE, because it cannot be LIMITed, the thus might
    # be to expensive in a single statement.
    # We could use select_for_update(), but there is no need for consistency
    # between multiple podcasts.
    to_update = Podcast.objects.filter(search_index_uptodate=False).only("pk")[
        :MAX_INDEX
    ]

    count = to_update.count()
    logger.info("Updating search index for {} podcasts".format(count))

    vectors = _get_search_vectors()

    for podcast in to_update:
        Podcast.objects.filter(pk=podcast.pk).update(
            search_vector=vectors, search_index_uptodate=True
        )

    logger.info("Finished indexing podcasts")
def update_search_index ( run_every = UPDATE_INTERVAL ) : logger . info ( "Updating search index" ) # We avoid an UPDATE, because it cannot be LIMITed, the thus might # be to expensive in a single statement. # We could use select_for_update(), but there is no need for consistency # between multiple podcasts. to_update = Podcast . objects . filter ( search_index_uptodate = False ) . only ( "pk" ) [ : MAX_INDEX ] count = to_update . count ( ) logger . info ( "Updating search index for {} podcasts" . format ( count ) ) vectors = _get_search_vectors ( ) for podcast in to_update : Podcast . objects . filter ( pk = podcast . pk ) . update ( search_vector = vectors , search_index_uptodate = True ) logger . info ( "Finished indexing podcasts" )