Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions _infra/helm/response-operations-ui/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version
version: 3.1.144
version: 3.1.145

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 3.1.144
appVersion: 3.1.145
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h2 class="ons-u-fs-r--b ons-u-pt-m">Sample file *</h2>
{
"tds": [
{
"value": "Sample loaded: " + '<em>' + sample.ingestDateTime[:-7] + '</em>' + sample.ingestDateTime[-7:]
"value": "Sample loaded: " + '<em>' + sample_ingest_date_time[:-7] + '</em>' + sample_ingest_date_time[-7:]
},
{
"value": addSampleLink,
Expand Down
35 changes: 18 additions & 17 deletions response_operations_ui/views/collection_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,23 @@ def _build_collection_instruments_details(collection_exercise_id: str, survey_id
@collection_exercise_bp.route("/<short_name>/<period>", methods=["GET"])
@login_required
def view_collection_exercise(short_name, period):
sample_load_status = None
sample_ingest_date_time =None
collection_exercise, survey = get_collection_exercise_and_survey_details(short_name, period)
sample = get_sample_summary(collection_exercise["id"])
events = convert_events_to_new_format(
collection_exercise_controllers.get_collection_exercise_events_by_id(collection_exercise["id"])
)
collection_instruments = _build_collection_instruments_details(collection_exercise["id"], survey["id"])
sample_load_status = None
if sample_controllers.sample_summary_state_check_required(collection_exercise["state"], sample):
try:
sample_load_status = sample_controllers.check_if_all_sample_units_present_for_sample_summary(sample["id"])
if sample_load_status["areAllSampleUnitsLoaded"]:
sample = _format_sample_summary(sample)

except ApiError:
flash("Sample summary check failed. Refresh page to try again", category="error")

if sample:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

House keeping, we don't want to do any sample work if we don't have a sample

if sample_controllers.sample_summary_state_check_required(collection_exercise["state"], sample):
try:
sample_load_status = sample_controllers.check_if_all_sample_units_present_for_sample_summary(sample["id"])

@LJBabbage LJBabbage Oct 17, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very badly named function, it actually updates the sample "state" to ACTIVE if the count is correct

@LJBabbage LJBabbage Oct 17, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically you submit a sample, and it's using this to update whether it is ready. The first pass will always be INIT and you get the loading sample page on the UI. The refresh/revisiting is used to see if it can transition. This isn't the best design unfortunately

except ApiError:
flash("Sample summary check failed. Refresh page to try again", category="error")
if sample["state"] in ["ACTIVE", "COMPLETE"]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are only interested in states Active and complete (see if in ce-sample-section.html), so we can use that as a way of deciding if we want to format the ingestion date/time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the state of the sample is anything but Active/complete, it will not show the bit where the date is shown

sample_ingest_date_time = _format_ingestion_date(sample.get("ingestDateTime"))

ce_state = collection_exercise["state"]
survey_mode = survey["surveyMode"]
Expand Down Expand Up @@ -163,6 +165,7 @@ def view_collection_exercise(short_name, period):
processing=processing,
sample_load_status=sample_load_status,
sample=sample,
sample_ingest_date_time=sample_ingest_date_time,
show_set_live_button=show_set_live_button,
survey=survey,
success_panel=success_panel,
Expand Down Expand Up @@ -465,14 +468,12 @@ def _validate_sample() -> bool:
return True


def _format_sample_summary(sample):
if sample and sample.get("ingestDateTime"):
submission_datetime = localise_datetime(iso8601.parse_date(sample["ingestDateTime"]))
submission_time = submission_datetime.strftime("%d %B %Y %I:%M%p")
sample["ingestDateTime"] = submission_time

@LJBabbage LJBabbage Oct 17, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to mess around with the sample, there is no need to pass it, then do checks, we only want the date and we know when to format it. We also don't want to mutate the sample, so we can just store and pass a separate var


return sample

def _format_ingestion_date(date_time):
try:
localised_submission_datetime = localise_datetime(iso8601.parse_date(date_time))
return localised_submission_datetime.strftime("%d %B %Y %I:%M%p")
except ValueError:
return date_time

def _format_ci_file_name(collection_instruments, survey_details):
for ci in collection_instruments:
Expand Down
Loading