Skip to content

Commit

Permalink
FSPT-208: serialise application date submitted in a guaranteed format
Browse files Browse the repository at this point in the history
`date_submitted` is stored both in the application table and in the JSON
representation of an application used by the assess tool.

Marshmallow will serialise the properties from the application model
depending on if there is timezone information included or not.
Previously the application store was first "submitting" an application
(updating the status and setting the `date_submitted` property) in
one database transaction and then separately fetching the application
and putting in on a queue to be processed by assess.

When we changed this behaviour to update the application and write to
the assessment table in one transaction we don't fetch a new application
from the database.

When the `date_submitted` property is set directly in the code we have
been including `timezone.utc` on the `datetime` property. When the
application is fetched from the database it does not include (or store)
the timezone information - I'm assuming everything by default is in UTC.

This means that we changed to serialising the JSON with timezone
information (`+00.00`) which caused issues when the assessment code
tried to serialise it.

This is one method of dealing with that and explicitly instructs
marshmallow to serialise the JSON (then stored in the `jsonb_blob`
property of assessments) using the format that has been used so far.
  • Loading branch information
sfount committed Jan 7, 2025
1 parent 02b16ed commit 8255ccb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions application_store/db/schemas/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ def get_round_name(self, obj):
started_at = DateTime(format="iso")
status = Enum(Status)
last_edited = DateTime(format="iso")
date_submitted = DateTime(format="%Y-%m-%dT%H:%M:%S.%f")
round_name = Method("get_round_name")
forms = Nested(FormsRunnerSchema, many=True, allow_none=True)

0 comments on commit 8255ccb

Please sign in to comment.