Merge pull request #769 from tcely/patch-3

Access `posix_epoch` correctly
This commit is contained in:
meeb 2025-02-25 02:15:21 +11:00 committed by GitHub
commit 8738e65bce
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 "{}")
if '_reduce_data_ran_at' in data.keys():
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):
return data
@ -1132,7 +1132,7 @@ class Media(models.Model):
if timestamp is not None:
try:
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:
log.warn(f'Could not compute published from timestamp for: {self.source} / {self} with "{e}"')
return published_dt