-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a scheduled task to reindex stale calendar caches periodically, s…
…o they it is not always being refreshed with a page load.
- Loading branch information
1 parent
822a1d6
commit a4db180
Showing
6 changed files
with
81 additions
and
8 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
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
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,28 @@ | ||
import logging | ||
|
||
from django.conf import settings | ||
|
||
from conf.celery import app | ||
from helium.common.utils import metricutils | ||
from helium.feed.services import icalexternalcalendarservice | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2023, Helium Edu" | ||
__version__ = "1.4.51" | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@app.task(bind=True) | ||
def reindex_external_calendars(): | ||
metrics = metricutils.task_start("reindex_external_calendars") | ||
|
||
icalexternalcalendarservice.reindex_stale_caches() | ||
|
||
metricutils.task_stop(metrics) | ||
|
||
|
||
@app.on_after_finalize.connect | ||
def setup_periodic_tasks(sender, **kwargs): # pragma: no cover | ||
# Add schedule to reindex external calendars periodically | ||
sender.add_periodic_task(settings.EXTERNAL_CALENDAR_REINDEX_FREQUENCY_SEC, reindex_external_calendars.s()) |
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