Skip to content

Commit

Permalink
feat(es): add is_data_embargoed to RunDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
wiwski committed Jul 16, 2024
1 parent adc0d91 commit 36e7cf6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lab/elasticsearch/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _create_project_page_data(
energy_in_kev=run.energy_in_keV,
beamline=run.beamline,
project_slug=run.project.slug,
is_data_embargoed=run.is_data_embargoed,
),
methods=method_model_to_dto(run),
)
Expand Down Expand Up @@ -111,6 +112,7 @@ def _create_object_group_page_data(projects: list[Project], runs: list[Run]):
energy_in_kev=run.energy_in_keV,
beamline=run.beamline,
project_slug=run.project.slug,
is_data_embargoed=run.is_data_embargoed,
),
methods=method_model_to_dto(run),
)
Expand Down
1 change: 1 addition & 0 deletions lab/elasticsearch/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class RunDoc(os.InnerDoc):
beamline = os.Keyword()
methods = os.Object(MethodDoc, multi=True)
project_slug = os.Keyword()
is_data_embargoed = os.Boolean()

def add_method(
self,
Expand Down
2 changes: 2 additions & 0 deletions lab/elasticsearch/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_build_project_catalog_document():
"energy_in_kev": run.energy_in_keV,
"particle_type": run.particle_type,
"project_slug": run.project.slug,
"is_data_embargoed": run.is_data_embargoed,
}
]
assert document.project_page_data.object_groups == [
Expand Down Expand Up @@ -125,6 +126,7 @@ def test_build_object_group_catalog_document():
"energy_in_kev": run.energy_in_keV,
"particle_type": run.particle_type,
"project_slug": run.project.slug,
"is_data_embargoed": run.is_data_embargoed,
}
]
assert document.object_page_data.projects == [
Expand Down
4 changes: 4 additions & 0 deletions lab/runs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ def next_status(self) -> Status:
except IndexError as exception:
raise AttributeError("Run has no next status") from exception
return next_status

@property
def is_data_embargoed(self):
return self.embargo_date is None or self.embargo_date > timezone.now().date()

0 comments on commit 36e7cf6

Please sign in to comment.