From 23563c7188e089929b60f9e10721c6fc43a220ff Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 22 Jun 2023 23:06:12 +0200 Subject: Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated) --- .../node_modules/pronote-api/src/fetch/absences.js | 114 --------------------- 1 file changed, 114 deletions(-) delete mode 100644 includes/external/school/node_modules/pronote-api/src/fetch/absences.js (limited to 'includes/external/school/node_modules/pronote-api/src/fetch/absences.js') diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/absences.js b/includes/external/school/node_modules/pronote-api/src/fetch/absences.js deleted file mode 100644 index 9c1ac02..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/absences.js +++ /dev/null @@ -1,114 +0,0 @@ -const { getPeriodBy } = require('../data/periods'); -const { withId, checkDuplicates } = require('../data/id'); - -const getAbsences = require('./pronote/absences'); - -// eslint-disable-next-line complexity -async function absences(session, user, period = null, from = null, to = null, type = null) -{ - const result = { - absences: [], - delays: [], - punishments: [], - other: [], - totals: [] - }; - - const p = getPeriodBy(session, !period && !type && from && to ? 'Trimestre 1' : period, type); - const absences = await getAbsences(session, user, p, from || p.from, to || p.to); - if (!absences) { - return null; - } - - for (const event of absences.events) { - // eslint-disable-next-line default-case - switch (event.type) { - case 'absence': - result.absences.push(withId({ - from: event.from, - to: event.to, - justified: event.justified, - solved: event.solved, - hours: event.hours, - reason: event.reasons.length && event.reasons[0].name || '' - }, ['from', 'to'])); - break; - case 'delay': - result.delays.push(withId({ - date: event.date, - justified: event.justified, - solved: event.solved, - justification: event.justification, - minutesMissed: event.duration, - reason: event.reasons.length && event.reasons[0].name || '' - }, ['data', 'minutesMissed'])); - break; - case 'punishment': - // eslint-disable-next-line no-case-declarations - let detention = null; - if (event.nature.type === 1) { - const schedule = event.schedule[0]; - const hour = session.params.firstHour.getHours() + schedule.position / session.params.ticksPerHour; - - const from = new Date(schedule.date.getTime()); - const to = new Date(schedule.date.getTime()); - - from.setHours(from.getHours() + hour); - to.setHours(to.getHours() + hour); - to.setMinutes(to.getMinutes() + schedule.duration); - - detention = { from, to }; - } - - result.punishments.push(withId({ - date: event.date, - isExclusion: event.isExclusion, - isDuringLesson: !event.isNotDuringLesson, - homework: event.homework, - circumstances: event.circumstances, - giver: event.giver.name, - reason: event.reasons.length && event.reasons[0].name || '', - detention - }, ['data'])); - break; - case 'other': - result.other.push(withId({ - kind: event.name, - date: event.date, - giver: event.giver.name, - comment: event.comment, - subject: event.subject && event.subject.name || null - }, ['kind', 'date'])); - break; - } - } - - Object.values(result).forEach(checkDuplicates); - - if (absences.subjects) { - for (const subject of absences.subjects) { - if (subject.inGroup) { - continue; - } - - const res = parseSubject(subject); - if (subject.group) { - res.subs = absences.subjects.filter(s => s.inGroup === subject.group).map(s => parseSubject(s)); - } - - result.totals.push(res); - } - } - - return result; -} - -function parseSubject(subject) { - return { - subject: subject.name, - hoursAssisted: subject.hoursAssisted, - hoursMissed: subject.hoursMissed - }; -} - -module.exports = absences; -- cgit