add Timestamp to multiple models (#796)

Expose the Azure storage table's "Timestamp" for the models where Timestamp should be user-accessible and remove the Timestamp field from models that did not sign up for it.

The behavior where Timestamp is only set by Azure Storage is kept.
This commit is contained in:
bmc-msft
2021-04-13 15:03:25 -04:00
committed by GitHub
parent 39464dc606
commit 470e95c833
5 changed files with 19 additions and 8 deletions

View File

@ -17,12 +17,12 @@ class TaskEvent(BASE_TASK_EVENT, ORMMixin):
@classmethod
def get_summary(cls, task_id: UUID) -> List[TaskEventSummary]:
events = cls.search(query={"task_id": [task_id]})
# handle None case of Optional[e.Timestamp], which shouldn't happen
events.sort(key=lambda e: e.Timestamp or datetime.datetime.max)
# handle None case of Optional[e.timestamp], which shouldn't happen
events.sort(key=lambda e: e.timestamp or datetime.datetime.max)
return [
TaskEventSummary(
timestamp=e.Timestamp,
timestamp=e.timestamp,
event_data=get_event_data(e.event_data),
event_type=get_event_type(e.event_data),
)