CodeWithAloha / HIERR

A Human-Centered Digital Engagement Process for the Hawai‘i Economic Recovery & Resilience Project with the State Office of Planning & Sustainable Development
https://hierr.vercel.app/
8 stars 7 forks source link

Add county and region columns to export #146

Closed avenmia closed 11 months ago

avenmia commented 11 months ago

Scott requested two additional export columns based on the user's answer for the workshop question in the demographic survey. The first column is county and the second is region. The value is stored in the database as a hyphenated value. This PR should add the two columns in the export and the values should be based on the user's answer.

Prisma wouldn't let me use findUnique so I used findFirst. I don't think this should cause issues, but let me know if it does. If a user retakes the demographic survey, it should erase the original answers and replace them so each userId and question should have a unique value.

vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hierr ✅ Ready (Inspect) Visit Preview Aug 12, 2023 10:20pm
dinoboy197 commented 11 months ago

Prisma wouldn't let me use findUnique so I used findFirst. I don't think this should cause issues, but let me know if it does.

I can't test this locally (travelling right now) but I think this is because the query predicate is not based on the primary key of the user survey answers table; it's based on two columns which might have duplicates (for example, the table definition probably doesn't disallow multiple rows with the same (user xid, question id) values). I'm not familiar with this table, but as long as our code doesn't insert multiple rows with the same (user xid, question id) tuple, then we're all good.

dinoboy197 commented 11 months ago

Have you tested this locally and confirmed it to work? I can't run this locally so I can't confirm it myself, but my instinct tells me that you may need to chain the new promises together with the old ones rather than trying to run them in parallel.

If it all works locally for you, let me know and I'll approve!

avenmia commented 11 months ago

@dinoboy197 It did work locally, but if the promises are not chained could they be inserted in a different order?