-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from istresearch/dev/next into develop
add EXPORT_TASK_CHECK_HOURS env var instead of hard-coded 4 hours.
- Loading branch information
Showing
3 changed files
with
32 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
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,27 @@ | ||
from datetime import timedelta | ||
|
||
from django.conf import settings | ||
from django.utils import timezone | ||
|
||
from engage.utils.class_overrides import ClassOverrideMixinMustBeFirst, ignoreDjangoModelAttrs | ||
|
||
from temba.utils.export import BaseExportTask | ||
|
||
class BaseExportTaskOverrides(ClassOverrideMixinMustBeFirst, BaseExportTask): | ||
override_ignore = ignoreDjangoModelAttrs(BaseExportTask) | ||
|
||
# we do not want Django to perform any magic inheritance | ||
class Meta: | ||
abstract = True | ||
|
||
@classmethod | ||
def get_recent_unfinished(cls, org): | ||
""" | ||
Checks for unfinished exports created recently for this org, and returns the most recent | ||
""" | ||
recent_hours = settings.EXPORT_TASK_CHECK_HOURS if hasattr(settings, 'EXPORT_TASK_CHECK_HOURS') else 4 | ||
recent_past = timezone.now() - timedelta(hours=recent_hours) | ||
return cls.get_unfinished().filter(org=org, created_on__gt=recent_past).order_by("created_on").last() | ||
#enddef get_recent_unfinished | ||
|
||
#endclass BaseExportTaskOverrides |
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