Fixed date usage
This commit is contained in:
@@ -112,6 +112,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const assigneesData = data.assignees
|
||||
.map((assignee: string) => {
|
||||
const userStats = allStats.filter((s: any) => s.user === assignee);
|
||||
const dates = userStats.map((s: any) => moment(s.date));
|
||||
return {
|
||||
userId: assignee,
|
||||
user: users.find((u) => u.id === assignee),
|
||||
@@ -126,6 +127,8 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
},
|
||||
{ correct: 0, missing: 0, total: 0 }
|
||||
),
|
||||
firstDate: moment.min(...dates),
|
||||
lastDate: moment.max(...dates),
|
||||
stats: userStats,
|
||||
};
|
||||
})
|
||||
@@ -135,13 +138,8 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const highestScore = Math.max(...results);
|
||||
const lowestScore = Math.min(...results);
|
||||
const averageScore = results.reduce((a, b) => a + b, 0) / results.length;
|
||||
|
||||
const dates = assigneesData
|
||||
.flatMap((r: any) => r.stats)
|
||||
.map((r: any) => r.date)
|
||||
.map((d: number) => moment(d));
|
||||
const firstDate = moment.min(dates);
|
||||
const lastDate = moment.max(dates);
|
||||
const firstDate = moment.min(assigneesData.map((r: any) => r.firstDate));
|
||||
const lastDate = moment.max(assigneesData.map((r: any) => r.lastDate));
|
||||
|
||||
const firstSectionData = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user