From ce4ad76f859bdc0ef5b9a0a11562df1825158f74 Mon Sep 17 00:00:00 2001 From: Thibault Guillou Date: Thu, 12 Dec 2024 16:15:54 +0100 Subject: [PATCH] conflict server --- server/controllers/statistics.ts | 59 ++++++++++++-------------------- server/stats/sessionStats.ts | 3 -- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/server/controllers/statistics.ts b/server/controllers/statistics.ts index 7286c89dd..9a97120be 100644 --- a/server/controllers/statistics.ts +++ b/server/controllers/statistics.ts @@ -7,7 +7,6 @@ import { getChildrenCodesCountForClassroom, getConnectedFamiliesCountForClassroom, getFamiliesWithoutAccountForClassroom, - normalizeForCountry, } from '../stats/classroomStats'; import { getChildrenCodesCountForGlobal, @@ -174,46 +173,32 @@ statisticsController.get({ path: '/classrooms' }, async (req, res) => { const classroomsData = await queryBuilder.getRawMany(); - const transformedData = classroomsData.map((classroom) => ({ - classroomId: classroom.classroomId, - classroomName: classroom.classroomName, - classroomCountryCode: classroom.classroomCountryCode, - villageId: classroom.villageId, - villageName: classroom.villageName, - commentsCount: parseInt(classroom.commentsCount, 10), - videosCount: parseInt(classroom.videosCount, 10), - userFirstName: classroom.userFirstname, - userLastName: classroom.userLastname, - activities: classroom.activitiesCount - ? classroom.activitiesCount.flatMap((phaseObj: { activities: any[]; phase: string }) => - phaseObj.activities.map((activity) => ({ - count: activity.count, - type: activity.type, - phase: phaseObj.phase, - })), - ) - : [], // Si activitiesCount est null, retourner une liste vide - })); - - const result = { data: [...transformedData], phases: normalizeForCountry(transformedData) }; + // const transformedData = classroomsData.map((classroom) => ({ + // classroomId: classroom.classroomId, + // classroomName: classroom.classroomName, + // classroomCountryCode: classroom.classroomCountryCode, + // villageId: classroom.villageId, + // villageName: classroom.villageName, + // commentsCount: parseInt(classroom.commentsCount, 10), + // videosCount: parseInt(classroom.videosCount, 10), + // userFirstName: classroom.userFirstname, + // userLastName: classroom.userLastname, + // activities: classroom.activitiesCount + // ? classroom.activitiesCount.flatMap((phaseObj: { activities: any[]; phase: string }) => + // phaseObj.activities.map((activity) => ({ + // count: activity.count, + // type: activity.type, + // phase: phaseObj.phase, + // })), + // ) + // : [], + // })); + + // const result = { data: [...transformedData], phases: normalizeForCountry(transformedData) }; res.sendJSON(classroomsData); - - // res.sendJSON( - // classroomsData.map((classroom) => ({ - // ...classroom, - // commentsCount: parseInt(classroom.commentsCount, 10), - // videosCount: parseInt(classroom.videosCount, 10), - // })), - // ); }); -// statisticsController.get({ path: '/classrooms' }, async (_req, res) => { -// res.sendJSON({ -// classrooms: await getClassroomsInfos(), -// }); -// }); - statisticsController.get({ path: '/onevillage' }, async (_req, res) => { res.sendJSON({ familyAccountsCount: await getFamilyAccountsCountForGlobal(), diff --git a/server/stats/sessionStats.ts b/server/stats/sessionStats.ts index 30051f220..f0688b1f5 100644 --- a/server/stats/sessionStats.ts +++ b/server/stats/sessionStats.ts @@ -1,10 +1,7 @@ import { AnalyticSession } from '../entities/analytic'; -import { UserType } from '../entities/user'; import { AppDataSource } from '../utils/data-source'; const analyticSessionRepository = AppDataSource.getRepository(AnalyticSession); -const durationThreshold = 60; -const teacherType = UserType.TEACHER; export const getMinDuration = async (villageId?: number | null, countryCode?: string | null, classroomId?: number | null) => { const queryBuilder = analyticSessionRepository