Skip to content

Commit

Permalink
Merge pull request #94 from AfricasVoices/analysis-snapshot-creation-…
Browse files Browse the repository at this point in the history
…date-time

Add creation_date_time to AnalysisSnapshot
  • Loading branch information
as2388 authored Jun 8, 2023
2 parents 240955e + ea74177 commit 4f4ff27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion analysis_dashboard/analysis_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def create_snapshot(self, series_id, files, bucket_name):
:type bucket_name: str
"""
snapshot = AnalysisSnapshot(
files=list(files.values())
files=list(files.values()),
creation_date_time=firestore.firestore.SERVER_TIMESTAMP
)

log.info(f"Creating new analysis snapshot with id {snapshot.snapshot_id}...")
Expand Down
7 changes: 6 additions & 1 deletion analysis_dashboard/data_models/analysis_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ class AnalysisSnapshot:
datasets were generated.
"""

def __init__(self, files, snapshot_id=None):
def __init__(self, files, creation_date_time, snapshot_id=None):
"""
:param files: List of files available.
:type files: list of str
:param creation_date_time: The date and time when this snapshot was created in Firestore.
:type creation_date_time: datetime.datetime
:param snapshot_id: Id of this analysis snapshot. If None, a message id will automatically be generated in
the constructor.
:type snapshot_id: str | None
Expand All @@ -20,6 +22,7 @@ def __init__(self, files, snapshot_id=None):
snapshot_id = str(uuid.uuid4())

self.snapshot_id = snapshot_id
self.creation_date_time = creation_date_time
self.files = files

def to_dict(self):
Expand All @@ -31,6 +34,7 @@ def to_dict(self):
"""
return {
"snapshot_id": self.snapshot_id,
"creation_date_time": self.creation_date_time,
"files": self.files,
"tags": [],
"tag_categories": []
Expand All @@ -48,5 +52,6 @@ def from_dict(cls, d):
"""
return cls(
d["snapshot_id"],
d["creation_date_time"],
d["files"]
)

0 comments on commit 4f4ff27

Please sign in to comment.