-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Celery task for updating CommunityAggregatedFields
Refs TS-1850
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import logging | ||
from typing import Optional | ||
|
||
from celery import shared_task | ||
|
||
from thunderstore.community.models import Community, CommunityAggregatedFields | ||
from thunderstore.core.settings import CeleryQueues | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@shared_task(queue=CeleryQueues.BackgroundTask) | ||
def update_community_aggregated_fields(batch_size: Optional[int] = None) -> None: | ||
communities = Community.objects.all() | ||
logger.info(f"Updating aggregated fields for {communities.count()} communities") | ||
|
||
CommunityAggregatedFields.update_for_communities(communities, batch_size) | ||
logger.info("CommunityAggregatedFields updated") |
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