-
Notifications
You must be signed in to change notification settings - Fork 0
Survey responses and download report end point #7
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
base: develop
Are you sure you want to change the base?
Conversation
controller/report.js
Outdated
|
||
// close the stream | ||
writeStream.end(); | ||
const name = "report.csv"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
report name should include survey title too.
controller/surveyResponses.js
Outdated
|
||
const surveyResponses = async (req, res) => { | ||
try { | ||
const surveys = await JoinSurvey.find({ surveyId: req.params.id }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name it Responses instead of JoinSurveys.
controller/report.js
Outdated
let path = __dirname; | ||
path = path.replace("controller", ""); | ||
path = path + "assets/report.csv"; | ||
const writeStream = fs.createWriteStream(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use csv stringify package for csv generation.
controller/report.js
Outdated
writeStream.write("\n"); | ||
} | ||
|
||
writeStream.on("finish", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use csv-stringify for csv report generation.
controller/report.js
Outdated
const Survey = require("../models/survey"); | ||
const Responses = require("../models/responses"); | ||
const fs = require("fs"); | ||
const { stringify } = require("csv-stringify"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line if the package is not included in the project.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Deployment failed with the following error:
|
Deployment failed with the following error:
Learn More: https://vercel.link/invalid-route-source-pattern |
No description provided.