Skip to content

Commit

Permalink
Add county and region columns to export (#146)
Browse files Browse the repository at this point in the history
* Adding county and location to export. The values are determined by splitting the userSurveyAnswer for the work shop question

* Updating location column name to be region
  • Loading branch information
avenmia authored Aug 16, 2023
1 parent ef477b6 commit 7143429
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/pages/api/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ const handler = nc({
},
});

// Gets the row for the survey answer for the question "What is your workshop?"
// This is question 16 in the survey
const surveyAnswerPromise = prisma.userSurveyAnswers.findFirst({
where: {
userId: row.xid,
questionId: "16",
},
});
const surveyPromise = surveyAnswerPromise.then((answer) => {
if (answer !== null) {
let [county, region] = answer.answerValue.split("-");
row.county = county;
row.region = region;
} else {
row.county = "";
row.region = "";
}
return row;
});

// add census tract and zipcode to the row if they are available
const rowPromise = userPromise.then((user) => {
var censusTract = "";
Expand All @@ -90,9 +110,12 @@ const handler = nc({

// push the row into an array to resolve during end callback
output.push(rowPromise);
output.push(surveyPromise);
} else {
row.censustract = "";
row.zipcode = "";
row.county = "";
row.region = "";
output.push(Promise.resolve(row));
}
})
Expand Down

1 comment on commit 7143429

@vercel
Copy link

@vercel vercel bot commented on 7143429 Aug 16, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

hierr – ./

hierr-codeforhawaii.vercel.app
hierr-git-main-codeforhawaii.vercel.app
hierr.vercel.app

Please sign in to comment.