Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Use full precision timestamps in JSON responses#790

Merged
lfdebrux merged 1 commit into
mainfrom
ldeb-use-full-timestamp-precision
Jul 9, 2025
Merged

Use full precision timestamps in JSON responses#790
lfdebrux merged 1 commit into
mainfrom
ldeb-use-full-timestamp-precision

Conversation

@lfdebrux
Copy link
Copy Markdown
Contributor

@lfdebrux lfdebrux commented Jul 9, 2025

What problem does this pull request solve?

Currently we store timestamps with microsecond precision (the default and maximum for PostgreSQL), but over the wire we only send milliseconds (the default for Rails). This is fine for most purposes, but as we're migrating data from forms-api to forms-admin at the moment it's helpful to get the full precision so we can easily compare the contents of the two databases without noise from truncated timestamps.

This commit uses the ActiveSupport configuration parameter to change the TimeWithZone#as_json method to return all 6 digits of precision.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Has all relevant documentation been updated?

Currently we store timestamps with microsecond precision (the default
and maximum for PostgreSQL), but over the wire we only send milliseconds
(the default for Rails). This is fine for most purposes, but as we're
migrating data from forms-api to forms-admin at the moment it's helpful
to get the full precision so we can easily compare the contents of the
two databases without noise from truncated timestamps.

This commit uses the ActiveSupport configuration parameter to change the
`TimeWithZone#as_json` method to return all 6 digits of precision.
@lfdebrux lfdebrux force-pushed the ldeb-use-full-timestamp-precision branch from 2225144 to d9c1758 Compare July 9, 2025 08:31
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jul 9, 2025

@lfdebrux lfdebrux enabled auto-merge July 9, 2025 08:37
Copy link
Copy Markdown
Contributor

@thomasiles thomasiles left a comment

Choose a reason for hiding this comment

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

good idea 👍

@lfdebrux lfdebrux merged commit 90069e9 into main Jul 9, 2025
4 checks passed
@lfdebrux lfdebrux deleted the ldeb-use-full-timestamp-precision branch July 9, 2025 08:42
lfdebrux added a commit to govuk-forms/forms-admin that referenced this pull request Aug 29, 2025
In forms-api PR govuk-forms/forms-api#790 we increased the precision of
timestamps when serializing to the maximum; we should do the same in
forms-admin.
SamJamCul pushed a commit to govuk-forms/forms-admin that referenced this pull request Aug 29, 2025
In forms-api PR govuk-forms/forms-api#790 we increased the precision of
timestamps when serializing to the maximum; we should do the same in
forms-admin.
SamJamCul added a commit to govuk-forms/forms-admin that referenced this pull request Aug 29, 2025
In forms-api PR govuk-forms/forms-api#790 we increased the precision of
timestamps when serializing to the maximum; we should do the same in
forms-admin.

Co-authored-by: Samuel Culley <samuel.culley@digital.cabinet-office.gov.uk>
Co-authored-by: Stephen Daly <stephen.daly@digital.cabinet-office.gov.uk>
Co-authored-by: Laurence de Bruxelles <laurence.debruxelles@dsit.gov.uk>
SamJamCul added a commit to govuk-forms/forms-admin that referenced this pull request Aug 29, 2025
In forms-api PR govuk-forms/forms-api#790 we increased the precision of
timestamps when serializing to the maximum; we should do the same in
forms-admin.

Co-authored-by: Samuel Culley <samuel.culley@digital.cabinet-office.gov.uk>
Co-authored-by: Stephen Daly <stephen.daly@digital.cabinet-office.gov.uk>
Co-authored-by: Laurence de Bruxelles <laurence.debruxelles@dsit.gov.uk>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants