Skip to content

Commit

Permalink
Always return datetime object in util function
Browse files Browse the repository at this point in the history
  • Loading branch information
jingcheng16 committed Dec 16, 2024
1 parent 82b1dfc commit 27aa65f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 0 additions & 3 deletions corehq/apps/enterprise/enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from datetime import datetime, timedelta

from django.conf import settings
from dimagi.utils.parsing import ISO_DATETIME_FORMAT
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy

Expand Down Expand Up @@ -484,8 +483,6 @@ def rows_for_domain(self, domain, config):

# Remove seconds and microseconds to reduce the number of unique timestamps
# This helps with performance because get_latest_version_at_time is memoized
if isinstance(date_of_use, str):
date_of_use = datetime.strptime(date_of_use, ISO_DATETIME_FORMAT)
date_of_use_minute_precision = date_of_use.replace(second=0, microsecond=0)

latest_version_at_time_of_use = get_latest_version_at_time(config, date_of_use_minute_precision)
Expand Down
4 changes: 4 additions & 0 deletions corehq/apps/reports/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from dimagi.utils.dates import DateSpan
from dimagi.utils.logging import notify_exception
from dimagi.utils.parsing import ISO_DATETIME_FORMAT

from celery.schedules import crontab

Expand Down Expand Up @@ -878,4 +879,7 @@ def get_commcare_version_and_date_from_last_usage(last_submission=None, last_dev
if version:
version_in_use = format_commcare_version(version) if formatted else version

if isinstance(date_of_use, str):
date_of_use = datetime.strptime(date_of_use, ISO_DATETIME_FORMAT)

return version_in_use, date_of_use

0 comments on commit 27aa65f

Please sign in to comment.