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

validate: Validate Raw Data, store in DB #23

Merged
1 commit merged into from
Jun 23, 2020
Merged

validate: Validate Raw Data, store in DB #23

1 commit merged into from
Jun 23, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jun 23, 2020

No description provided.

@ghost ghost requested a review from michaelwood June 23, 2020 14:36
@ghost ghost self-assigned this Jun 23, 2020
@ghost
Copy link
Author

ghost commented Jun 23, 2020

#14 for notes - raw data, filter only some results, and it's a % we show on the results page

Technically we don't need validation_passed - you could do validation_results==[] to get the same but setting up this should make for some very easy SQL queries to get the data we need for generating the stat, and some space efficient indexes later.

@@ -0,0 +1,3 @@
ALTER TABLE raw_data ADD validation_done BOOLEAN NOT NULL DEFAULT 'f';
ALTER TABLE raw_data ADD validation_passed BOOLEAN NOT NULL DEFAULT 'f';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a blocker, would prefer the SQL compliant FALSE or TRUE whenever possible. I had to look up what postgres accepts for booleans. Then you won't have to spend energy escaping quotes later on too.

try {
await client.query(
'UPDATE raw_data SET validation_done= \'t\', validation_results=$1, validation_passed=$2 WHERE id=$3',
[JSON.stringify(result_filtered), (result_filtered.length == 0), raw_data.id]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your === above reminded me we probably want an === here too. It is good practice in JS to keep the equivalency(?) consistent .

To run this:

`$ node ./src/bin/validate-raw-data.js`

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could really use npm run scripts, the advantage of those is that you avoid encoding the filename/path in lots of places. Though perhaps this is the only place anyway.

Copy link
Author

Choose a reason for hiding this comment

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

#27

Copy link
Author

Choose a reason for hiding this comment

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

When we set up Heroku some more hard coded paths will appear so this is a good point


const client = await database_pool.connect();
try {
while(true) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering if you're expecting this to be OK to fail?

Copy link
Author

Choose a reason for hiding this comment

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

Not confident, but this applies to many other places and we need a general review of handling error conditions #26

@ghost ghost merged commit 5efbe32 into master Jun 23, 2020
@ghost ghost deleted the validate-raw-data branch July 22, 2020 10:37
This pull request was closed.
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