-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add appeals to BOPS endpoints in PostsubmissionSchema format (DSNPI-1008) #2196
base: main
Are you sure you want to change the base?
Add appeals to BOPS endpoints in PostsubmissionSchema format (DSNPI-1008) #2196
Conversation
@@ -0,0 +1,23 @@ | |||
# frozen_string_literal: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, we usually convert datetimes to YYYY-MM-DD
format with foo.to_date.to_s
.
(Normally we'd display dates as YYYY-MM-DD
and datetimes as full ISO8601, but we might still have a few datetimes that should probably be stored as dates and so we truncate those — and of course if there's an external requirement for a particular format.)
I'd be really suspicious if we need to display a date in full ISO8601 format though, I wouldn't want to make it look like we have more accuracy in the data than we actually do. (But I don't think the format_postsubmission_datetime
method is actually being used?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok so would you suggest I switch to using foo.to_date.to_s
in this helper? Does it ensure that the returned result is utc?
I still need to do a final walkthrough of the date/datetime setup for the postSubmission - for now I've followed the same setup as we had before but I still feel for some aspects a full date time would be useful for context and auditing even if its never shown in the back/frontend.
(and yeh format_postsubmission_datetime
was just me adding in both types of dates the postsubmission supports its not actually used yet!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are definitely places where we store a datetime even if in practice we never actually show it: I think it's good for recording when an event actually occurred specifically. (So I think it normally ends up being datetimes for the past, dates for the future: like deadlines and so on.)
My only concern about using a datetime when we store only a date is that it might be misleading, for cases like deadlines, to include 00:00:00
when in practice it's probably actually going to be the start or end of the working day or something like that. But obviously there might be other situations I haven't thought of where it does make sense to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think theres currently any data thats being stored in BOPS as a date expecting to be returned as a dateTime in the new schema - though it may be in the future that we end up having to update some to be dateTimes in BOPS just so we're not returning empty times.
json.partial! "bops_api/v2/public/shared/show", planning_application: planning_application | ||
json.partial! "bops_api/v2/shared/postsubmissionApplication/postsubmissionApplication", planning_application: planning_application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can leave the variable name out here and the variable with the same name as the key will be used:
json.partial! "bops_api/v2/public/shared/show", planning_application: planning_application | |
json.partial! "bops_api/v2/shared/postsubmissionApplication/postsubmissionApplication", planning_application: planning_application | |
json.partial! "bops_api/v2/public/shared/show", planning_application: | |
json.partial! "bops_api/v2/shared/postsubmissionApplication/postsubmissionApplication", planning_application: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made that change! its so weird because it gave me no end of arguments the other day when I left it out and now its behaving! 🤷♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK now the error has come back! any idea what would be causing this? I've put the code back to how it was for now to be able to use the endpoint (I've rebuild and rerun the container and it still errors)
json.partial! "bops_api/v2/shared/metadata"
json.data @planning_applications do |planning_application|
json.partial! "bops_api/v2/public/shared/show", planning_application:
json.partial! "bops_api/v2/shared/postsubmissionApplication/postsubmissionApplication", planning_application:
end
This error only shows when engines/bops_api/app/views/bops_api/v2/public/search.json.jbuilder
is :
# frozen_string_literal: true
json.partial! "bops_api/v2/shared/metadata"
json.data @planning_applications do |planning_application|
json.partial! "bops_api/v2/public/shared/show", planning_application:
json.partial! "bops_api/v2/shared/postsubmissionApplication/postsubmissionApplication", planning_application:
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What errors are you getting from this? It appears to work fine when I change it but I might be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh maybe its that file loading issue @pixeltrix and I were talking about yesterday! (or possibly the rubocop formatting I'm using vscode!)
b803a28
to
6be3478
Compare
@@ -0,0 +1,29 @@ | |||
# frozen_string_literal: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests all fail because they refer to methods that don't exist: should it be format_postsubmission_date
and format_postsubmission_datetime
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never thought I'd miss husky running the tests every five minutes! Fixed now hopefully!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few places where Rubocop is showing up formatting errors: mainly whitespace/newlines and quote marks — could you run rubocop --autocorrect
and update the PR with the changes, please?
@@ -0,0 +1,18 @@ | |||
# frozen_string_literal: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've found in the past that it's easier to define a schema for things if we have values that are always present, but potentially nil, rather than being omitted if they're nil.
So in this case we'd probably leave off the if-statements in this file and just let it return the nils.
But you're the API consumer (and probably more familiar with jsonschema than me) so would be open to your perspective on that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, I see what you mean. I've mostly followed the convention from the PrototypeApplication
and since the schema is generated from TypeScript, the general recommendation is to use field?: string
rather than field: string | null
. It's also much easier to work with field?: string
when dealing directly with the types. 😅. It may also be, and I'd need to check this, that the library that converts TypeScript to Json-Schema (ts-json-schema-generator
) is opinionated on this?
In the examples I have purposely left out fields that are not relevant or applicable to the application - Appeal determined application vs Council determined application. Data not being present in a result usually means that is is optional and/or not applicable? which is definitely true in the case of appeal data though it may not be the case for some of the other fields later on! If you can no longer submit an appeal after 6 months then appeal: null
being present would seem odd and could imply you can still appeal?
c1c2328
to
c3fd9ae
Compare
# @param date [DateTime, Time, nil] the date to be formatted | ||
# @return [String, nil] the formatted date string or nil if the date is nil | ||
def format_postsubmission_date(date) | ||
date&.utc&.strftime("%Y-%m-%d") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, Andrew has suggested that this could be
date&.utc&.strftime("%Y-%m-%d") | |
date&.utc&.to_date.iso8601 |
Which I think might make the intent even clearer?
(I'm actually not sure if utc
is even needed when we're only dealing with dates, since the DST change should never change the date — it'd be different if we had to deal with times outside the UK.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've been getting ahead of myself here tbh, I've changed the functionality and description of this helper to reflect its role as go between for dates stored as datetimes that should be dates until they get converted some day!
Theres an issue here to standardise the dates as UTC in the API endpoints and use the at/date naming convention too. Even though this standard is currently only used in the UK, it's pretty standard to use UTC in APIs for consistency. We currently get all sorts of different date formats back from BOPS/PlanX so it would be good to agree on one format.
c3fd9ae
to
a65a942
Compare
Hey!
We will slowly be submitting PR's to convert the public endpoints to the ODP schema for the DPR, this one is for the appeals section.
Description of change
This PR makes a change to the
v2 public search
andv2 public show
endpoints to return appeals in the structure we've put in the PostsubmissionApplication schema and the DPR.Decisions
engines/bops_api/app/views/bops_api/v2/shared/
and not public as the intention is in the future to add a newPublishedSubmission
schema which is a subset of thePostsubmission
and this would require moving and renaming all sorts of files down the line when currently everything we're doing applies at this top level.PostsubmissionApplicationSchemaHelper
as a starting point for Post submission specific formattingKnown issues
I haven't updated the
swagger_doc.yml
as I was having trouble validating it in the swagger editor - hoping to get some tips on this from this PR!I have also kept the tests fairly minimal, I have some example's documented in the ODP schema repo which might be good to build tests against as we build up the new schema but I felt adding all that was a little beyond the scope of this PR - something to discuss in our next call?