SIENTIAPDE-1193

refactor: standardize timestamp handling across MongoDB and SlotManager

- Replaced instances of `now()` with `date_now` for consistent timestamp usage in MongoDB and SlotManager activities.
- Updated test cases to mock the new `now()` function, ensuring accurate timestamp handling in unit tests.
- Adjusted timestamp formatting in various tests to align with the DATETIME_FORMAT_MS_WITH_TZ standard.
This commit is contained in:
vitor-aignosi
2025-08-25 08:30:42 -03:00
parent d7effd44e5
commit 4aa7ea70fa
5 changed files with 39 additions and 34 deletions

View File

@@ -216,7 +216,7 @@ class MongoDB(BaseActivity):
"""
updated_pipelines = input_data.get("updated_pipelines", [])
metadata = input_data.get("metadata", {})
now = now()
date_now = now()
collection = self.database["orchestrated_schedules"]
self.info("Updating pipelines timestamps...", metadata=metadata)
@@ -233,7 +233,7 @@ class MongoDB(BaseActivity):
try:
collection.update_many(
data_filter,
{"$set": {"updated_at": now}}
{"$set": {"updated_at": date_now}}
)
success_count += 1
except Exception as e:
@@ -267,12 +267,12 @@ class MongoDB(BaseActivity):
success_count = 0
now = now()
date_now = now()
argument = [
{"schedule_name": pipeline["schedule_name"],
"namespace": pipeline["namespace"],
"updated_at": now}
"updated_at": date_now}
for pipeline in created_pipelines if pipeline["success"]
]
data_filter = argument if argument else {}

View File

@@ -382,12 +382,12 @@ class SlotManager(Redis):
self.info("Storing notification cache...", metadata=metadata)
now = now().strftime(DATETIME_FORMAT_MS_WITH_TZ)
date_now = now().strftime(DATETIME_FORMAT_MS_WITH_TZ)
for index, row in log_report.iterrows():
status = row['status']
if status == 'sent':
key = f"{row['schedule']}:{row['notification_id']}"
self.set(key, now, ttl=sent_ttl)
self.set(key, date_now, ttl=sent_ttl)
self.info("Notification cache stored...", metadata=metadata)