diff --git a/client/src/components/metrics/Graph.tsx b/client/src/components/metrics/Graph.tsx index 4316c63..f8a3454 100644 --- a/client/src/components/metrics/Graph.tsx +++ b/client/src/components/metrics/Graph.tsx @@ -47,197 +47,206 @@ export default function Graph() { Number of Students per Day (in the last week) - + dateFormatter(day.day)), - datasets: [ - { - label: 'Number of Students', - data: numStudentsPerDayLastWeek.map((day) => day.students), - fill: false, - backgroundColor: theme.palette.primary.main, - borderColor: theme.palette.primary.main, - borderWidth: 3, - tension: 0.3, - }, - ], - }} - /> + }} + + data={{ + labels: numStudentsPerDayLastWeek.map((day) => dateFormatter(day.day)), + datasets: [ + { + label: 'Number of Students', + data: numStudentsPerDayLastWeek.map((day) => day.students), + fill: false, + backgroundColor: theme.palette.primary.main, + borderColor: theme.palette.primary.main, + borderWidth: 3, + tension: 0.3, + }, + ], + }} + /> + Number of Students per Day (overall) - + dateFormatter(day.day)), - datasets: [ - { - label: 'Number of Students', - data: numStudentsOverall.map((day) => day.students), - fill: false, - backgroundColor: theme.palette.primary.main, - borderColor: theme.palette.primary.main, - borderWidth: 3, - tension: 0.3, - }, - ], - }} - /> + }} + + data={{ + labels: numStudentsOverall.map((day) => dateFormatter(day.day)), + datasets: [ + { + label: 'Number of Students', + data: numStudentsOverall.map((day) => day.students), + fill: false, + backgroundColor: theme.palette.primary.main, + borderColor: theme.palette.primary.main, + borderWidth: 3, + tension: 0.3, + }, + ], + }} + /> + Number of Students per Day of the Week - + day.day), - datasets: [ - { - label: 'Number of Students', - data: numStudentsPerDay.map((day) => day.students), - backgroundColor: theme.palette.primary.main, - borderColor: theme.palette.primary.main, - borderWidth: 3, - }, - ], - }} - /> + }} + data={{ + labels: numStudentsPerDay.map((day) => day.day), + datasets: [ + { + label: 'Number of Students', + data: numStudentsPerDay.map((day) => day.students), + backgroundColor: theme.palette.primary.main, + borderColor: theme.palette.primary.main, + borderWidth: 3, + }, + ], + }} + /> + ); } diff --git a/server/controllers/metrics.js b/server/controllers/metrics.js index e4b0d49..25b4038 100644 --- a/server/controllers/metrics.js +++ b/server/controllers/metrics.js @@ -294,7 +294,7 @@ exports.get_num_students_per_day_last_week = (req, res) => { models.question.findAll({ attributes: [ - [Sequelize.fn('date', Sequelize.col('entry_time')), 'day'], + [Sequelize.fn('date', Sequelize.literal(`"entry_time" AT TIME ZONE 'EST'`)), 'day'], [Sequelize.fn('count', Sequelize.col('question_id')), 'count'] ], where: { @@ -302,7 +302,7 @@ exports.get_num_students_per_day_last_week = (req, res) => { [Sequelize.Op.gte]: new Date(today - 7 * 24 * 60 * 60 * 1000), } }, - group: [Sequelize.fn('date', Sequelize.col('entry_time'))], + group: [Sequelize.fn('date', Sequelize.literal(`"entry_time" AT TIME ZONE 'EST'`))], order: [[Sequelize.col('day'), 'ASC']] }).then((data) => { let numStudentsPerDayLastWeek = []; @@ -325,10 +325,10 @@ exports.get_num_students_per_day = (req, res) => { models.question.findAll({ attributes: [ - [Sequelize.fn('date_part', 'dow', Sequelize.col('entry_time')), 'day_of_week'], + [Sequelize.fn('date_part', 'dow', Sequelize.literal(`"entry_time" AT TIME ZONE 'EST'`)), 'day_of_week'], [Sequelize.fn('count', Sequelize.col('question_id')), 'count'] ], - group: [Sequelize.fn('date_part', 'dow', Sequelize.col('entry_time'))], + group: [Sequelize.fn('date_part', 'dow', Sequelize.literal(`"entry_time" AT TIME ZONE 'EST'`))], order: [[Sequelize.col('count'), 'DESC']] }).then((data) => { let numStudentsPerDay = []; @@ -352,10 +352,10 @@ exports.get_num_students_overall = (req, res) => { models.question.findAll({ attributes: [ - [Sequelize.fn('date', Sequelize.col('entry_time')), 'day'], + [Sequelize.fn('date', Sequelize.literal(`"entry_time" AT TIME ZONE 'EST'`)), 'day'], [Sequelize.fn('count', Sequelize.col('question_id')), 'count'] ], - group: [Sequelize.fn('date', Sequelize.col('entry_time'))], + group: [Sequelize.fn('date', Sequelize.literal(`"entry_time" AT TIME ZONE 'EST'`))], order: [[Sequelize.col('day'), 'ASC']] }).then((data) => { let numStudentsOverall = [];