From a41a910332b4dbea2ef20c2ec3d70d9225bcb01f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 26 Sep 2026 06:50:31 +0000 Subject: [PATCH] Refactor: remove dead code, fix stale docstring, tighten server any types - Remove commented-out unused ManyToOne/JoinColumn block on StudentByYear view entity (no inverse-side reference uses it, unlike User.entity.ts's intentionally-kept pattern). - Remove two commented-out disabled export-header columns (approvedAbsCount/sheetName) referencing fields that don't exist on AttReportWithReportMonth. - Remove unused DateInput import/commented filters in student-percent-report.jsx, unused MichlolPopulatedFileParams import in its spec, unused gradeAvg/lessonsCount destructure in michlolPopulatedFile.ts, and a leftover client console.log. - Fix stale YemotHandlerService class docstring: it no longer just "returns a maintenance mode message", it routes manager/seminar/ transportation call flows. - Replace several server-side `any` types with real types where safe (student-percent-report.config.ts's debug field and fetchAttGradeEffect's viewEntity param, student-by-year.config.ts's header thresholds field) verified with `tsc --noEmit`. - DRY: att-report-with-report-month.config.ts's deleteOne now reuses the existing getAttReportService() helper instead of duplicating the BaseEntityService construction. Left @dataui/crud-tied `any` (CrudRequest, doAction/ populatePivotData overrides, req.parsed.extra/filter.value) alone: their `any` originates in the nra-server shared submodule's own base class signatures and the crud-request library's types, so narrowing them here isn't safely possible without changing that submodule. All existing tests verified passing before and after (server: 119 suites/ 1155 tests; client: 34 suites/214 tests), plus a clean `tsc --noEmit`. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017mJpVpL5fuvKVhGyMPLeUh --- .../useFileProcessor.js | 1 - .../src/entities/student-percent-report.jsx | 4 +--- .../db/view-entities/StudentByYear.entity.ts | 4 ---- .../att-report-with-report-month.config.ts | 4 +--- .../entity-modules/student-by-year.config.ts | 7 ++++-- .../student-percent-report.config.ts | 23 +++++++++++++++---- .../__tests__/michlolPopulatedFile.spec.ts | 2 +- server/src/reports/michlolPopulatedFile.ts | 2 +- server/src/yemot-handler.service.ts | 5 ++-- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/client/src/components/ApprovedAbsencesUpload/useFileProcessor.js b/client/src/components/ApprovedAbsencesUpload/useFileProcessor.js index be365861..e55588c5 100644 --- a/client/src/components/ApprovedAbsencesUpload/useFileProcessor.js +++ b/client/src/components/ApprovedAbsencesUpload/useFileProcessor.js @@ -101,7 +101,6 @@ export const useFileProcessor = (setFileName, setPreviewData, setLoading) => { const matched = matchResults.filter((r) => r.matched).length; const notMatched = matchResults.filter((r) => !r.matched).length; - console.log('Match Results:', matchResults); setPreviewData({ total: validRows.length, matched, diff --git a/client/src/entities/student-percent-report.jsx b/client/src/entities/student-percent-report.jsx index f96e13b2..5a189daa 100644 --- a/client/src/entities/student-percent-report.jsx +++ b/client/src/entities/student-percent-report.jsx @@ -1,4 +1,4 @@ -import { DateInput, NumberField, TextField, ReferenceField, useRecordContext, TextInput } from 'react-admin'; +import { NumberField, TextField, ReferenceField, useRecordContext, TextInput } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; @@ -14,8 +14,6 @@ import { adminUserFilter } from '@shared/components/fields/PermissionFilter'; const filters = [ adminUserFilter, - // , - // , Student, { createForeignKeyConstraints: false }) - // @JoinColumn({ name: 'id' }) - // student: Student; } diff --git a/server/src/entity-modules/att-report-with-report-month.config.ts b/server/src/entity-modules/att-report-with-report-month.config.ts index 20a0bf8a..40307e42 100644 --- a/server/src/entity-modules/att-report-with-report-month.config.ts +++ b/server/src/entity-modules/att-report-with-report-month.config.ts @@ -59,8 +59,6 @@ function getConfig(): BaseEntityModuleOptions { { value: getHebrewDateFormatter('reportDate'), label: 'תאריך עברי' }, { value: 'howManyLessons', label: 'מספר שיעורים' }, { value: 'absCount', label: 'מספר חיסורים' }, - // { value: 'approvedAbsCount', label: 'מספר חיסורים מאושרים' }, - // { value: 'sheetName', label: 'חודש דיווח' }, { value: 'comments', label: 'הערות' }, ]; if (!shouldShowTopic(req)) { @@ -108,7 +106,7 @@ class AttReportWithReportMonthService): Promise { - const attReportService = new BaseEntityService(this.dataSource.getRepository(AttReport), this.mailSendService); + const attReportService = this.getAttReportService(); return attReportService.deleteOne(req) as Promise; } diff --git a/server/src/entity-modules/student-by-year.config.ts b/server/src/entity-modules/student-by-year.config.ts index d48ab7f6..d3f53c0f 100644 --- a/server/src/entity-modules/student-by-year.config.ts +++ b/server/src/entity-modules/student-by-year.config.ts @@ -12,7 +12,7 @@ import { Klass } from 'src/db/entities/Klass.entity'; import { formatPercent } from '@shared/utils/formatting/formatter.util'; import { roundAllNumericProperties } from '@shared/utils/reportData.util'; import { getAsNumberArray } from '@shared/utils/queryParam.util'; -import { ABSENCE_THRESHOLDS } from 'src/utils/absenceThresholds'; +import { ABSENCE_THRESHOLDS, AbsenceThreshold } from 'src/utils/absenceThresholds'; function getConfig(): BaseEntityModuleOptions { return { @@ -197,7 +197,10 @@ class StudentByYearService extends BaseEntityS }), ]); - const headers: Record = {}; + const headers: Record< + string, + { value: string; label: string; numFmt?: string; thresholds?: readonly AbsenceThreshold[] } + > = {}; const rawAbs: Record> = {}; const rawLessons: Record> = {}; const rawKnownAbs: Record> = {}; diff --git a/server/src/entity-modules/student-percent-report.config.ts b/server/src/entity-modules/student-percent-report.config.ts index 46d72eb6..aacf7f3d 100644 --- a/server/src/entity-modules/student-percent-report.config.ts +++ b/server/src/entity-modules/student-percent-report.config.ts @@ -22,7 +22,7 @@ import { IGradeEffect, } from 'src/utils/studentReportData.util'; import { getKnownAbsenceFilterBySprAndDates, getReportDataFilterBySprAndDates } from 'src/utils/studentReportData.util'; -import { DataSource, In } from 'typeorm'; +import { DataSource, EntityTarget, FindOptionsWhere, In } from 'typeorm'; function getConfig(): BaseEntityModuleOptions { return { @@ -67,6 +67,13 @@ function getConfig(): BaseEntityModuleOptions { }; } +interface IStudentPercentReportDebug { + absCountEffectId: string; + gradeEffectId: string; + absCountEffect: IGradeEffect; + gradeEffect: IGradeEffect; +} + interface StudentPercentReportWithDates extends StudentPercentReport { approvedAbsCount?: number; attGradeEffect?: number; @@ -74,7 +81,7 @@ interface StudentPercentReportWithDates extends StudentPercentReport { finalAttendance?: string; estimation?: string; comments?: string; - debug?: any; + debug?: IStudentPercentReportDebug; } class StudentPercentReportService extends BaseEntityService { protected async populatePivotData(pivotName: string, list: T[], extra: any, filter: any, auth: any) { @@ -205,9 +212,15 @@ function getGradeEffectId(item: StudentPercentReportWithDates): string { return `${item.userId}_${Math.floor(item.attPercents * 100)}`; } -function fetchAttGradeEffect( +interface IEffectViewRow { + id: string; + effect: number; + effectPercent: number; +} + +function fetchAttGradeEffect( dataSource: DataSource, - viewEntity: any, + viewEntity: EntityTarget, ids: string[], ): Promise> { return dataSource @@ -215,7 +228,7 @@ function fetchAttGradeEffect( .find({ where: { id: In(ids), - }, + } as FindOptionsWhere, select: ['id', 'effect', 'effectPercent'], }) .then((arr) => diff --git a/server/src/reports/__tests__/michlolPopulatedFile.spec.ts b/server/src/reports/__tests__/michlolPopulatedFile.spec.ts index 7e559261..9e1340d0 100644 --- a/server/src/reports/__tests__/michlolPopulatedFile.spec.ts +++ b/server/src/reports/__tests__/michlolPopulatedFile.spec.ts @@ -5,7 +5,7 @@ import { Student } from 'src/db/entities/Student.entity'; import { AttReportAndGrade } from 'src/db/view-entities/AttReportAndGrade.entity'; import { KnownAbsence } from 'src/db/entities/KnownAbsence.entity'; import { AttGradeEffect } from 'src/db/entities/AttGradeEffect'; -import michlolPopulatedFile, { MichlolPopulatedFileParams } from '../michlolPopulatedFile'; +import michlolPopulatedFile from '../michlolPopulatedFile'; import * as yearUtil from '@shared/utils/entity/year.util'; import * as reportDataUtil from '@shared/utils/reportData.util'; import * as studentReportDataUtil from 'src/utils/studentReportData.util'; diff --git a/server/src/reports/michlolPopulatedFile.ts b/server/src/reports/michlolPopulatedFile.ts index 4664fd2e..ee6773fd 100644 --- a/server/src/reports/michlolPopulatedFile.ts +++ b/server/src/reports/michlolPopulatedFile.ts @@ -74,7 +74,7 @@ const getReportData: IGetReportDataFunction = async ( const studentReports = studentReportsMap[studentId] || []; const studentKnownAbsences = knownAbsencesMap[studentId] || []; - const { attPercents, absCount, approvedAbsCount, gradeAvg, lessonsCount, lastGrade } = calcReportsData( + const { attPercents, absCount, approvedAbsCount, lastGrade } = calcReportsData( studentReports, studentKnownAbsences, ); diff --git a/server/src/yemot-handler.service.ts b/server/src/yemot-handler.service.ts index e29ddb7c..d9c43b9b 100644 --- a/server/src/yemot-handler.service.ts +++ b/server/src/yemot-handler.service.ts @@ -16,8 +16,9 @@ import { Between, In } from 'typeorm'; const SCHEDULE_MATCH_TOLERANCE_MINUTES = 90; /** - * Yemot Handler Service for processing incoming Yemot calls - * Currently returns a maintenance mode message + * Yemot Handler Service for processing incoming Yemot calls. + * Hangs up with a maintenance message when configured; otherwise routes to the + * manager report status, seminar attendance, or transportation report flow. */ @Injectable()