alphagov / e-petitions

This is the code base for the UK Government's e-petitions service (https://petition.parliament.uk)
https://petition.parliament.uk
MIT License
305 stars 77 forks source link

Include both original and revised government responses in the json feed #782

Open johnhzhu opened 3 years ago

johnhzhu commented 3 years ago

When there is a revised government response, return the original government response in the Json feed. Currently only the revised government response is in the Json feed.

pixeltrix commented 3 years ago

As we discussed in our meeting the original response is stored as an 'Other parliamentary business' item which corresponds to a Petition::Email within the application. Previously these weren't made available in the JSON feed but as of today they are under the key path data.attributes.other_parliamentary_business which returns an array of objects with the keys subject, body, created_at and updated_at. An example can be found on petition 302576 and a screenshot of the output is below:

image

johnhzhu commented 3 years ago

Thanks. That is quite helpful. Could the actual date of the original government response be reflected in the created_at field or a new field such as responded_on in the json data? For the example you gave, it is stated that original response was published on 7 July 2020 in the body text, but the json field created_at has value 2020-09-15. If the published dates are included, we can easily put multiple government responses in a timeline order.

pixeltrix commented 3 years ago

There's a government_response_at field which is the timestamp of that first government response being created. The responded_on property of the government_response object is the date of the latest government response and then the created_at of the other business object is the timestamp that the new government response was added. This isn't ideal but should allow you to reconstruct the timeline.

johnhzhu commented 3 years ago

Thanks for your quick reply. For the example: government_response_at contains 2020-07-08, but in the body text says 7 July 2020. Seems inconsistent. Will there be a chance that there are two or more revised government responses? If that happens, harder to reconstruct the timeline?

pixeltrix commented 3 years ago

For the example: government_response_at contains 2020-07-08, but in the body text says 7 July 2020. Seems inconsistent.

The government_response_at is an auto generated timestamp so the fact that it's recorded as the next day seems consistent with the official response date of 7 July 2020.

Will there be a chance that there are two or more revised government responses?

Possibly, yes - however a search of the data suggests only 11 amended responses in nearly 6 years and never twice for the same petition.

I agree that all this is not ideal - there is a backlog item to make amended government responses a thing within the application. However that would require spending of maintenance budget to implement - I'm happy to do so if you want to have a chat with Ben Sneddon or Ed Faulkner on the Petitions team.