Skip to content

Commit

Permalink
conflict server
Browse files Browse the repository at this point in the history
  • Loading branch information
dodoLaprovence committed Dec 12, 2024
1 parent 1ad6f62 commit ce4ad76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 40 deletions.
59 changes: 22 additions & 37 deletions server/controllers/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
getChildrenCodesCountForClassroom,
getConnectedFamiliesCountForClassroom,
getFamiliesWithoutAccountForClassroom,
normalizeForCountry,
} from '../stats/classroomStats';
import {
getChildrenCodesCountForGlobal,
Expand Down Expand Up @@ -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(),
Expand Down
3 changes: 0 additions & 3 deletions server/stats/sessionStats.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ce4ad76

Please sign in to comment.