Skip to content

Sample tidy up#1035

Open
LJBabbage wants to merge 10 commits into
mainfrom
sample-tidy-up
Open

Sample tidy up#1035
LJBabbage wants to merge 10 commits into
mainfrom
sample-tidy-up

Conversation

@LJBabbage

@LJBabbage LJBabbage commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

What and why?

Just an example how to fix an issue

How to test?

Jira

@LJBabbage LJBabbage requested a review from a team as a code owner October 17, 2025 16:06
sample_load_status = sample_controllers.check_if_all_sample_units_present_for_sample_summary(sample["id"])
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

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

if 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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants