@cronjobs.register
def update_collections_votes():
 up = CollectionVote.objects.values('collection_id').annotate(count=Count('collection')).filter(vote=1).extra(where=['DATE(created)=%s'], params=[date.today()])
 down = CollectionVote.objects.values('collection_id').annotate(count=Count('collection')).filter(vote=(-1)).extra(where=['DATE(created)=%s'], params=[date.today()])
 ts = [_update_collections_votes.subtask(args=[chunk, 'new_votes_up']) for chunk in chunked(up, 1000)]
 TaskSet(ts).apply_async()
 ts = [_update_collections_votes.subtask(args=[chunk, 'new_votes_down']) for chunk in chunked(down, 1000)]
 TaskSet(ts).apply_async()

@ cronjobs . register def update_collections_votes ( ) : up = CollectionVote . objects . values ( 'collection_id' ) . annotate ( count = Count ( 'collection' ) ) . filter ( vote = 1 ) . extra ( where = [ 'DATE(created)=%s' ] , params = [ date . today ( ) ] ) down = CollectionVote . objects . values ( 'collection_id' ) . annotate ( count = Count ( 'collection' ) ) . filter ( vote = ( - 1 ) ) . extra ( where = [ 'DATE(created)=%s' ] , params = [ date . today ( ) ] ) ts = [ _update_collections_votes . subtask ( args = [ chunk , 'new_votes_up' ] ) for chunk in chunked ( up , 1000 ) ] TaskSet ( ts ) . apply_async ( ) ts = [ _update_collections_votes . subtask ( args = [ chunk , 'new_votes_down' ] ) for chunk in chunked ( down , 1000 ) ] TaskSet ( ts ) . apply_async ( )
update collections votes .