Skip to content

Commit 690046a

Browse files
committed
rename today -> now
1 parent 391b7bc commit 690046a

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

packages/grzctl/src/grzctl/commands/db/cli.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -941,14 +941,14 @@ def change_request(ctx: click.Context, submission_id: str, change_str: str, data
941941
raise click.ClickException(f"Failed to update submission state: {e}") from e
942942

943943

944-
def _research_consented_today(submission: Submission) -> bool | None:
945-
"""Research consent for the submission re-evaluated as of today.
944+
def _research_consented_now(submission: Submission) -> bool | None:
945+
"""Research consent for the submission re-evaluated as of now.
946946
947947
Unlike the persisted ``consented`` field (evaluated at the submission date),
948-
this recomputes consent from the stored redacted metadata using today's date.
948+
this recomputes consent from the stored redacted metadata using the current date.
949949
950950
:param submission: Submission whose stored metadata to evaluate.
951-
:returns: ``True``/``False`` for the consent decision today, or ``None`` when
951+
:returns: ``True``/``False`` for the consent decision now, or ``None`` when
952952
no metadata is stored (e.g. rows migrated without backpopulated metadata)
953953
or when the stored metadata cannot be parsed.
954954
"""
@@ -957,17 +957,17 @@ def _research_consented_today(submission: Submission) -> bool | None:
957957
try:
958958
metadata = GrzSubmissionMetadata.model_validate(submission.submission_metadata)
959959
except ValidationError:
960-
log.debug("Could not parse stored metadata for submission %s to evaluate consent today.", submission.id)
960+
log.debug("Could not parse stored metadata for submission %s to evaluate consent now.", submission.id)
961961
return None
962962
return metadata.consents_to_research(date=date.today())
963963

964964

965-
def _build_attribute_table(submission: Submission, research_consented_today: bool | None) -> rich.table.Table:
965+
def _build_attribute_table(submission: Submission, research_consented_now: bool | None) -> rich.table.Table:
966966
"""Build the attribute table shown by ``submission show``.
967967
968968
:param submission: Submission to render.
969-
:param research_consented_today: Research consent re-evaluated as of today
970-
(see :func:`_research_consented_today`), or ``None`` when unavailable.
969+
:param research_consented_now: Research consent re-evaluated as of now
970+
(see :func:`_research_consented_now`), or ``None`` when unavailable.
971971
:returns: A populated rich table of submission attributes.
972972
"""
973973
attribute_table = rich.table.Table(box=None)
@@ -994,11 +994,11 @@ def _build_attribute_table(submission: Submission, research_consented_today: boo
994994
rich.text.Text(f"{label}", style="cyan"), rich.text.Text(str(attr)) if attr is not None else _TEXT_MISSING
995995
)
996996
if attr_name == "consented":
997-
# Adjacent row: research consent re-evaluated as of today (recomputed from stored metadata).
997+
# Adjacent row: research consent re-evaluated as of now (recomputed from stored metadata).
998998
attribute_table.add_row(
999-
rich.text.Text("Research consent (today)", style="cyan"),
1000-
rich.text.Text(str(research_consented_today))
1001-
if research_consented_today is not None
999+
rich.text.Text("Research consent (now)", style="cyan"),
1000+
rich.text.Text(str(research_consented_now))
1001+
if research_consented_now is not None
10021002
else _TEXT_MISSING,
10031003
)
10041004
return attribute_table
@@ -1019,11 +1019,11 @@ def show(ctx: click.Context, submission_id: str, output_json: bool):
10191019
console_err.print(f"[red]Error: Submission with ID '{submission_id}' not found.[/red]")
10201020
raise click.Abort()
10211021

1022-
research_consented_today = _research_consented_today(submission)
1022+
research_consented_now = _research_consented_now(submission)
10231023

10241024
if output_json:
10251025
submission_dict = submission.model_dump(mode="json")
1026-
submission_dict["research_consented_today"] = research_consented_today
1026+
submission_dict["research_consented_now"] = research_consented_now
10271027
submission_dict["states"] = []
10281028

10291029
for state_log in sorted(submission.states, key=lambda s: s.timestamp):
@@ -1043,7 +1043,7 @@ def show(ctx: click.Context, submission_id: str, output_json: bool):
10431043
sys.stdout.write("\n")
10441044
return
10451045

1046-
attribute_table = _build_attribute_table(submission, research_consented_today)
1046+
attribute_table = _build_attribute_table(submission, research_consented_now)
10471047

10481048
renderables: list[rich.console.RenderableType] = [rich.padding.Padding(attribute_table, (1, 0))]
10491049
if submission.states:

packages/grzctl/tests/cli/test_db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def test_submission_show_json(blank_database_config_path: Path, test_metadata_pa
731731
"disease_type": metadata.submission.disease_type,
732732
"basic_qc_passed": None,
733733
"consented": metadata.consents_to_research(date=metadata.submission.submission_date),
734-
"research_consented_today": metadata.consents_to_research(date=date.today()),
734+
"research_consented_now": metadata.consents_to_research(date=date.today()),
735735
"selected_for_qc": None,
736736
"detailed_qc_passed": None,
737737
"genomic_study_type": metadata.submission.genomic_study_type,
@@ -1114,5 +1114,5 @@ def test_submission_show_json_includes_failure_reason(blank_database_config_path
11141114
parsed = json.loads(result_show.stdout)
11151115
error_state = next(s for s in parsed["states"] if s["state"] == "Error")
11161116
assert error_state["failure_reason"] == "decryption_error"
1117-
# No metadata stored for this submission -> today's research consent cannot be evaluated.
1118-
assert parsed["research_consented_today"] is None
1117+
# No metadata stored for this submission -> current research consent cannot be evaluated.
1118+
assert parsed["research_consented_now"] is None

0 commit comments

Comments
 (0)