Access posix_epoch correctly

Fixes #768
This commit is contained in:
tcely 2025-02-24 10:11:06 -05:00 committed by GitHub
parent e45fce54bc
commit 1ad90ad628
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1018,7 +1018,7 @@ class Media(models.Model):
data = json.loads(self.metadata or "{}") data = json.loads(self.metadata or "{}")
if '_reduce_data_ran_at' in data.keys(): if '_reduce_data_ran_at' in data.keys():
total_seconds = data['_reduce_data_ran_at'] total_seconds = data['_reduce_data_ran_at']
ran_at = posix_epoch + timedelta(seconds=total_seconds) ran_at = self.posix_epoch + timedelta(seconds=total_seconds)
if (timezone.now() - ran_at) < timedelta(hours=1): if (timezone.now() - ran_at) < timedelta(hours=1):
return data return data
@ -1132,7 +1132,7 @@ class Media(models.Model):
if timestamp is not None: if timestamp is not None:
try: try:
timestamp_float = float(timestamp) timestamp_float = float(timestamp)
published_dt = posix_epoch + timedelta(seconds=timestamp_float) published_dt = self.posix_epoch + timedelta(seconds=timestamp_float)
except Exception as e: except Exception as e:
log.warn(f'Could not compute published from timestamp for: {self.source} / {self} with "{e}"') log.warn(f'Could not compute published from timestamp for: {self.source} / {self} with "{e}"')
return published_dt return published_dt