Skip to content

Commit

Permalink
Merge pull request #3 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Use utcnow instead of now for dates as ckan internal dates should always be utc based
  • Loading branch information
duttonw committed Aug 6, 2020
2 parents b67875b + 377d958 commit 362157d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ckanext/report/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Column('object_id', types.UnicodeText, index=True),
Column('key', types.UnicodeText, nullable=False),
Column('value', types.UnicodeText),
Column('created', types.DateTime, default=datetime.datetime.now),
Column('created', types.DateTime, default=datetime.datetime.utcnow),
)
Index('idx_data_cache_object_id_key', data_cache_table.c.object_id,
data_cache_table.c.key)
Expand Down Expand Up @@ -80,7 +80,7 @@ def get(cls, object_id, key, convert_json=False, max_age=None):
return (None, None)

if max_age:
age = datetime.datetime.now() - item.created
age = datetime.datetime.utcnow() - item.created
if age > max_age:
log.debug('Cache not returned - it is older than requested %s/%s %r > %r',
object_id, key, age, max_age)
Expand Down Expand Up @@ -125,7 +125,7 @@ def set(cls, object_id, key, value, convert_json=False):
model.Session.add(item)
else:
item.value = value
item.created = datetime.datetime.now()
item.created = datetime.datetime.utcnow()

log.debug('Cache save: %s/%s', object_id, key)
model.Session.flush()
Expand Down

0 comments on commit 362157d

Please sign in to comment.