Sample tidy up#1035
Conversation
| 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"]: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"]) |
There was a problem hiding this comment.
This is a very badly named function, it actually updates the sample "state" to ACTIVE if the count is correct
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
House keeping, we don't want to do any sample work if we don't have a sample
What and why?
Just an example how to fix an issue
How to test?
Jira