(interval=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 schedule_updates(interval=UPDATE_INTERVAL):
    """Schedules podcast updates that are due within ``interval``"""
    now = datetime.utcnow()

    # max number of updates to schedule (one every 10s)
    max_updates = UPDATE_INTERVAL.total_seconds() / 10

    # fetch podcasts for which an update is due within the next hour
    podcasts = (
        Podcast.objects.all()
        .next_update_between(now, now + interval)
        .prefetch_related("urls")
        .only("pk")[:max_updates]
    )

    _schedule_updates(podcasts)
def schedule_updates ( interval = UPDATE_INTERVAL ) : now = datetime . utcnow ( ) # max number of updates to schedule (one every 10s) max_updates = UPDATE_INTERVAL . total_seconds ( ) / 10 # fetch podcasts for which an update is due within the next hour podcasts = ( Podcast . objects . all ( ) . next_update_between ( now , now + interval ) . prefetch_related ( "urls" ) . only ( "pk" ) [ : max_updates ] ) _schedule_updates ( podcasts )