CSV Import is now working

This commit is contained in:
Mann Patel
2025-09-03 14:35:47 -06:00
parent 7f2b7e481a
commit 86d733e80e
20 changed files with 2160 additions and 1626 deletions

View File

@@ -88,7 +88,12 @@ func PollHandler(w http.ResponseWriter, r *http.Request) {
pollID := r.FormValue("poll_id")
postalCode := r.FormValue("postal_code")
// Parse integer values
question3LawnSigns, _ := strconv.Atoi(r.FormValue("question3_lawn_signs"))
question4BannerSigns, _ := strconv.Atoi(r.FormValue("question4_banner_signs"))
question5Thoughts := r.FormValue("question5_thoughts")
question6donation := r.FormValue("question6_amount")
// Parse boolean values
var question1VotedBefore *bool
@@ -115,19 +120,16 @@ func PollHandler(w http.ResponseWriter, r *http.Request) {
}
}
// Parse integer values
question3LawnSigns, _ := strconv.Atoi(r.FormValue("question3_lawn_signs"))
question4BannerSigns, _ := strconv.Atoi(r.FormValue("question4_banner_signs"))
// Insert poll response
_, err = models.DB.Exec(`
INSERT INTO poll_response (
poll_id, respondent_postal_code, question1_voted_before,
question2_vote_again, question3_lawn_signs, question4_banner_signs,
question5_thoughts
) VALUES ($1, $2, $3, $4, $5, $6, $7)
question5_thoughts, question6_donation_amount
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
`, pollID, postalCode, question1VotedBefore, question2VoteAgain,
question3LawnSigns, question4BannerSigns, question5Thoughts)
question3LawnSigns, question4BannerSigns, question5Thoughts, question6donation)
if err != nil {
fmt.Print(err)