Skip to content

Commit

Permalink
Merge pull request #47 from hiimchrislim/timezone
Browse files Browse the repository at this point in the history
convert timestamp from UTC to toronto
  • Loading branch information
hiimchrislim authored Aug 5, 2022
2 parents 82569aa + 8eff85e commit 2c244d7
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions server/src/controllers/pollController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function changePollStatus(pollId: string, hasStarted: boolean) {
EX: expiry,
});
const result = await pollResult(pollId, newSequence);
io.to(pollId).emit("result", result)
io.to(pollId).emit("result", result);
}
// for every stop make the current counter negative to indicate that it is not an active sequence
else {
Expand All @@ -63,29 +63,35 @@ async function getStudents(courseCode: string, startTime: Date, endTime: Date) {
const pollDoc = await PollModel.find({ courseCode });
let promises: Promise<any>[] = [];
let responses: any[] = [];
console.log(62, pollDoc);
pollDoc.forEach((element) => {
console.log(67, element._id);
promises.push(
StudentModel.find(
StudentModel.aggregate([
{
pollId: element._id.toString(),
timestamp: { $gte: startTime, $lte: endTime },
$match: {
pollId: element._id.toString(),
timestamp: { $gte: startTime, $lte: endTime },
},
},
{
_id: 0,
pollId: 1,
courseCode,
sequence: 1,
utorid: 1,
timestamp: 1,
pollName: element.name,
description: element.description,
answer: 1,
}
).then((data) => {
$project: {
_id: 0,
pollId: 1,
courseCode,
sequence: 1,
utorid: 1,
timestamp: {
$dateToString: {
date: "$timestamp",
timezone: "America/Toronto"
},
},
pollName: element.name,
description: element.description,
answer: 1,
},
},
]).then((data) => {
data.forEach((val) => {
console.log(75, val);
responses.push(val);
});
})
Expand Down

0 comments on commit 2c244d7

Please sign in to comment.