Skip to content
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

[96] CSV upload #56

Merged
merged 6 commits into from
Jul 25, 2023
Merged

[96] CSV upload #56

merged 6 commits into from
Jul 25, 2023

Conversation

steventux
Copy link
Contributor

@steventux steventux commented Jul 19, 2023

Context

We receive a CSV file from the Disclosure and Barring Service (weekly).
This CSV file contains details of any new additions to the barred list.

We need to store these additions within the service.

Changes proposed in this pull request

  • Adds a very basic upload UI.
  • UI is backed by service class which turns CSV data into ChildrensBarredListEntry records.
  • Existing records are matched by name and DOB, if additional fields TRN or National Insurance Number are supplied these will be updated on the existing record.
  • CSV parsing errors are handled in form errors and relevant error messages displayed to the user.

Support form for CSV uploads

image

Form validation

image

(CSV parse error)
image

Success

image

Guidance to review

Not in scope

  • Return how many records were added on the success page.
  • Display added records on the success page.

Link to Trello card

https://trello.com/c/MSBcR45T/96-csv-upload

Checklist

  • Attach to Trello card
  • Rebased main
  • Cleaned commit history
  • Tested by running locally

@steventux
Copy link
Contributor Author

CSV upload

Copy link
Contributor

@AbigailMcP AbigailMcP left a comment

Choose a reason for hiding this comment

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

Looking good!

@@ -0,0 +1,7 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

extra line

validates :last_name,
presence: true,
uniqueness: {
scope: %i[first_names date_of_birth]
Copy link
Contributor

Choose a reason for hiding this comment

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

This made me think - if there were two records with same last_name, first_names and date_of_birth, but one of them also had a trn / national_insurance_number, we might want to keep the one with more info / compare the two.

If that ever happened we should probably handle that manually though, rather than in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, if the first record to make it to the db is missing the TRN we'd never update it. I will make sure we update existing matches.

@@ -0,0 +1,8 @@
,SIMPSON,HOMER DUFF,19/01/1980 00:00,,N
,MOUSE,MICKEY,05/02/1980 00:00,,N
,MUFFET,LITTLE MISS,06/02/2000 00:00,,N
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I'm using your PR to think out loud 😂 - if the CSV ever had Mr/Miss etc in it, we might need to think about how we match on records. The risk is we return "No record found" when there is a matching record.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's a good point, I think we should strip the names of any titles, I was thinking that we need to standardise the case for the values so I'll add to this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@steventux nice! could defs be in a follow-up PR if you wanted.

@steventux steventux force-pushed the 96-csv-upload branch 4 times, most recently from 63242bc to 6f7c49f Compare July 24, 2023 11:06
@steventux steventux marked this pull request as ready for review July 24, 2023 11:13
@steventux steventux force-pushed the 96-csv-upload branch 2 times, most recently from 96ff15b to 5003eb1 Compare July 24, 2023 11:16
Copy link
Contributor

@AbigailMcP AbigailMcP left a comment

Choose a reason for hiding this comment

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

🚀

I'm still not 100% sure about how much we should format the names when we save them vs how much we format people's incoming searches for comparison, but i think we just need to test it out with various scenarios and make sure we're returning the best results.

@steventux
Copy link
Contributor Author

@AbigailMcP I see what you mean, presumably searching in a consistent case would be simpler?

    Adds an UploadForm which expects some form of IO instance which can be read by the service as CSV data.
    The service class creates a ChildrensBarredListEntry for each new row of CSV data.
Adds a very basic CSV upload form and system spec.
@steventux steventux merged commit 18ecd58 into main Jul 25, 2023
10 checks passed
@steventux steventux deleted the 96-csv-upload branch July 25, 2023 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants