diff --git a/client/shared b/client/shared index 6a884c1f..e9728015 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit 6a884c1f6f13c02cd2c735b0e923f2479ec74598 +Subproject commit e97280151cc346a5597ef07e94dd2c43054d962d diff --git a/client/src/domainTranslations.js b/client/src/domainTranslations.js index 21d685bd..43c343e5 100644 --- a/client/src/domainTranslations.js +++ b/client/src/domainTranslations.js @@ -341,6 +341,7 @@ export default { reportMonthReferenceId: 'תקופת דיווח', reportedLessons: 'שיעורים שדווחו', notReportedLessons: 'שיעורים שלא דווחו', + hasNotReportedLessons: 'יש שיעורים שלא דווחו', }, }, teacher_reported_today: { @@ -362,6 +363,7 @@ export default { reportMonthReferenceId: 'תקופת דיווח', reportedLessons: 'שיעורים שדווחו', notReportedLessons: 'שיעורים שלא דווחו', + hasNotReportedLessons: 'יש שיעורים שלא דווחו', }, }, student_percent_report: { diff --git a/client/src/entities/teacher-grade-report-status.jsx b/client/src/entities/teacher-grade-report-status.jsx index effb419d..006c0734 100644 --- a/client/src/entities/teacher-grade-report-status.jsx +++ b/client/src/entities/teacher-grade-report-status.jsx @@ -4,6 +4,7 @@ import { TextField, required, BooleanInput, + NullableBooleanInput, TextInput, useGetList, } from 'react-admin'; @@ -28,6 +29,7 @@ const filters = [ dynamicFilter={filterByUserId} />, , + , ]; const filterDefaultValues = { @@ -86,8 +88,8 @@ const Datagrid = ({ isAdmin, children, ...props }) => { - - + + ); }; diff --git a/client/src/entities/teacher-report-status.jsx b/client/src/entities/teacher-report-status.jsx index 72f61836..f21d9edb 100644 --- a/client/src/entities/teacher-report-status.jsx +++ b/client/src/entities/teacher-report-status.jsx @@ -4,6 +4,7 @@ import { TextField, required, BooleanInput, + NullableBooleanInput, TextInput, useGetList, } from 'react-admin'; @@ -28,6 +29,7 @@ const filters = [ dynamicFilter={filterByUserId} />, , + , ]; const filterDefaultValues = { @@ -86,8 +88,8 @@ const Datagrid = ({ isAdmin, children, ...props }) => { - - + + ); }; diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index 58eaf38d..7915c7ba 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -44,4 +44,6 @@ export default [ { html: 'רשימות: כפתור "מיון" למיון מתקדם לפי כמה עמודות (למשל סדר כיתה ואז שם מורה), כולל בייצוא לאקסל. בדוח שכר למורה אפשר למיין גם לפי סדר כיתה ושיוך כיתה', status: 'בוצע', statusColor: 'success' }, { html: 'מסך "קליטת קובץ נוכחות מגמה": הורדת קובץ אקסל מלא מראש לכיתה עם בלוק עמודות לכל מורה, והעלאתו אחרי הסימון ליצירה ועדכון של דיווחי נוכחות (בהרשאה)', status: 'בוצע', statusColor: 'success' }, { html: 'סיבות חיסור קבועות: בהגדרות מכניסים רשימת סיבות (חתונה, מחלה וכו\'), ובשדה "סיבה" בחיסורים מאושרים בוחרים מהרשימה או מקלידים סיבה אחרת', status: 'בוצע', statusColor: 'success' }, + { html: 'רשימות: שורת מעבר העמודים נשארת קבועה בתחתית המסך בזמן גלילה (במחשב)', status: 'בוצע', statusColor: 'success' }, + { html: 'דיווחים למורה וציונים למורה: סינון "יש שיעורים שלא דווחו", ומיון לפי מספר השיעורים שדווחו / שלא דווחו', status: 'בוצע', statusColor: 'success' }, ].reverse(); diff --git a/server/src/db/view-entities/TeacherGradeReportStatus.entity.ts b/server/src/db/view-entities/TeacherGradeReportStatus.entity.ts index 3911e7c6..20ac865f 100644 --- a/server/src/db/view-entities/TeacherGradeReportStatus.entity.ts +++ b/server/src/db/view-entities/TeacherGradeReportStatus.entity.ts @@ -47,6 +47,9 @@ import { getGroupConcatExpression } from '@shared/utils/entity/column-types.util ), 'notReportedLessonNames', ) + .addSelect('COUNT(DISTINCT CASE WHEN tlrs.isReported = 1 THEN tlrs.lessonId END)', 'reportedLessonsCount') + .addSelect('COUNT(DISTINCT CASE WHEN tlrs.isReported = 0 THEN tlrs.lessonId END)', 'notReportedLessonsCount') + .addSelect('COUNT(DISTINCT CASE WHEN tlrs.isReported = 0 THEN tlrs.lessonId END) > 0', 'hasNotReportedLessons') .from(TeacherLessonGradeReportStatus, 'tlrs') .leftJoin(Teacher, 'teacher', 'tlrs.teacherId = teacher.id') .leftJoin(ReportMonth, 'rm', 'tlrs.reportMonthId = rm.id') @@ -94,4 +97,13 @@ export class TeacherGradeReportStatus implements IHasUserId { @Column() notReportedLessonNames: string; + + @ViewColumn() + reportedLessonsCount: number; + + @ViewColumn() + notReportedLessonsCount: number; + + @ViewColumn() + hasNotReportedLessons: boolean; } diff --git a/server/src/db/view-entities/TeacherReportStatus.entity.ts b/server/src/db/view-entities/TeacherReportStatus.entity.ts index 970329a6..4c202170 100644 --- a/server/src/db/view-entities/TeacherReportStatus.entity.ts +++ b/server/src/db/view-entities/TeacherReportStatus.entity.ts @@ -47,6 +47,9 @@ import { getGroupConcatExpression } from '@shared/utils/entity/column-types.util ), 'notReportedLessonNames', ) + .addSelect('COUNT(DISTINCT CASE WHEN tlrs.isReported = 1 THEN tlrs.lessonId END)', 'reportedLessonsCount') + .addSelect('COUNT(DISTINCT CASE WHEN tlrs.isReported = 0 THEN tlrs.lessonId END)', 'notReportedLessonsCount') + .addSelect('COUNT(DISTINCT CASE WHEN tlrs.isReported = 0 THEN tlrs.lessonId END) > 0', 'hasNotReportedLessons') .from(TeacherLessonReportStatus, 'tlrs') .leftJoin(Teacher, 'teacher', 'tlrs.teacherId = teacher.id') .leftJoin(ReportMonth, 'rm', 'tlrs.reportMonthId = rm.id') @@ -94,4 +97,13 @@ export class TeacherReportStatus implements IHasUserId { @Column() notReportedLessonNames: string; + + @ViewColumn() + reportedLessonsCount: number; + + @ViewColumn() + notReportedLessonsCount: number; + + @ViewColumn() + hasNotReportedLessons: boolean; } diff --git a/server/src/migrations/1793215235847-AddLessonCountsToTeacherReportStatus.ts b/server/src/migrations/1793215235847-AddLessonCountsToTeacherReportStatus.ts new file mode 100644 index 00000000..bd60c19a --- /dev/null +++ b/server/src/migrations/1793215235847-AddLessonCountsToTeacherReportStatus.ts @@ -0,0 +1,332 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddLessonCountsToTeacherReportStatus1793215235847 implements MigrationInterface { + name = 'AddLessonCountsToTeacherReportStatus1793215235847' + + public async up(queryRunner: QueryRunner): Promise { + const dbName = queryRunner.connection.options.database; + await queryRunner.query(` + DELETE FROM \`${dbName}\`.\`typeorm_metadata\` + WHERE \`type\` = ? + AND \`name\` = ? + AND \`schema\` = ? + `, ["VIEW","teacher_report_status",dbName]); + await queryRunner.query(` + DROP VIEW \`teacher_report_status\` + `); + await queryRunner.query(` + DELETE FROM \`${dbName}\`.\`typeorm_metadata\` + WHERE \`type\` = ? + AND \`name\` = ? + AND \`schema\` = ? + `, ["VIEW","teacher_grade_report_status",dbName]); + await queryRunner.query(` + DROP VIEW \`teacher_grade_report_status\` + `); + await queryRunner.query(` + CREATE VIEW \`teacher_grade_report_status\` AS + SELECT \`tlrs\`.\`userId\` AS \`userId\`, + \`tlrs\`.\`year\` AS \`year\`, + \`tlrs\`.\`teacherId\` AS \`teacherId\`, + \`tlrs\`.\`reportMonthId\` AS \`reportMonthId\`, + \`teacher\`.\`name\` AS \`teacherName\`, + \`teacher\`.\`comment\` AS \`teacherComment\`, + \`rm\`.\`name\` AS \`reportMonthName\`, + CONCAT( + COALESCE(\`tlrs\`.\`userId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`teacherId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`reportMonthId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`year\`, "null") + ) AS \`id\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`reportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`notReportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`reportedLessonNames\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`notReportedLessonNames\`, + COUNT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonId\` + END + ) AS \`reportedLessonsCount\`, + COUNT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ) AS \`notReportedLessonsCount\`, + COUNT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ) > 0 AS \`hasNotReportedLessons\` + FROM \`teacher_lesson_grade_report_status\` \`tlrs\` + LEFT JOIN \`teachers\` \`teacher\` ON \`tlrs\`.\`teacherId\` = \`teacher\`.\`id\` + LEFT JOIN \`report_month\` \`rm\` ON \`tlrs\`.\`reportMonthId\` = \`rm\`.\`id\` + GROUP BY \`tlrs\`.\`userId\`, + \`tlrs\`.\`teacherId\`, + \`tlrs\`.\`reportMonthId\`, + \`tlrs\`.\`year\` + ORDER BY \`tlrs\`.\`reportMonthId\` ASC, + \`tlrs\`.\`teacherId\` ASC + `); + await queryRunner.query(` + INSERT INTO \`${dbName}\`.\`typeorm_metadata\`( + \`database\`, + \`schema\`, + \`table\`, + \`type\`, + \`name\`, + \`value\` + ) + VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?) + `, [dbName,"VIEW","teacher_grade_report_status","SELECT `tlrs`.`userId` AS `userId`, `tlrs`.`year` AS `year`, `tlrs`.`teacherId` AS `teacherId`, `tlrs`.`reportMonthId` AS `reportMonthId`, `teacher`.`name` AS `teacherName`, `teacher`.`comment` AS `teacherComment`, `rm`.`name` AS `reportMonthName`, CONCAT(COALESCE(`tlrs`.`userId`, \"null\"), \"_\", COALESCE(`tlrs`.`teacherId`, \"null\"), \"_\", COALESCE(`tlrs`.`reportMonthId`, \"null\"), \"_\", COALESCE(`tlrs`.`year`, \"null\")) AS `id`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `reportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `notReportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `reportedLessonNames`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `notReportedLessonNames`, COUNT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonId` END) AS `reportedLessonsCount`, COUNT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END) AS `notReportedLessonsCount`, COUNT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END) > 0 AS `hasNotReportedLessons` FROM `teacher_lesson_grade_report_status` `tlrs` LEFT JOIN `teachers` `teacher` ON `tlrs`.`teacherId` = `teacher`.`id` LEFT JOIN `report_month` `rm` ON `tlrs`.`reportMonthId` = `rm`.`id` GROUP BY `tlrs`.`userId`, `tlrs`.`teacherId`, `tlrs`.`reportMonthId`, `tlrs`.`year` ORDER BY `tlrs`.`reportMonthId` ASC, `tlrs`.`teacherId` ASC"]); + await queryRunner.query(` + CREATE VIEW \`teacher_report_status\` AS + SELECT \`tlrs\`.\`userId\` AS \`userId\`, + \`tlrs\`.\`year\` AS \`year\`, + \`tlrs\`.\`teacherId\` AS \`teacherId\`, + \`tlrs\`.\`reportMonthId\` AS \`reportMonthId\`, + \`teacher\`.\`name\` AS \`teacherName\`, + \`teacher\`.\`comment\` AS \`teacherComment\`, + \`rm\`.\`name\` AS \`reportMonthName\`, + CONCAT( + COALESCE(\`tlrs\`.\`userId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`teacherId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`reportMonthId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`year\`, "null") + ) AS \`id\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`reportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`notReportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`reportedLessonNames\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`notReportedLessonNames\`, + COUNT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonId\` + END + ) AS \`reportedLessonsCount\`, + COUNT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ) AS \`notReportedLessonsCount\`, + COUNT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ) > 0 AS \`hasNotReportedLessons\` + FROM \`teacher_lesson_report_status\` \`tlrs\` + LEFT JOIN \`teachers\` \`teacher\` ON \`tlrs\`.\`teacherId\` = \`teacher\`.\`id\` + LEFT JOIN \`report_month\` \`rm\` ON \`tlrs\`.\`reportMonthId\` = \`rm\`.\`id\` + GROUP BY \`tlrs\`.\`userId\`, + \`tlrs\`.\`year\`, + \`tlrs\`.\`teacherId\`, + \`tlrs\`.\`reportMonthId\` + ORDER BY \`tlrs\`.\`reportMonthId\` ASC, + \`tlrs\`.\`teacherId\` ASC + `); + await queryRunner.query(` + INSERT INTO \`${dbName}\`.\`typeorm_metadata\`( + \`database\`, + \`schema\`, + \`table\`, + \`type\`, + \`name\`, + \`value\` + ) + VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?) + `, [dbName,"VIEW","teacher_report_status","SELECT `tlrs`.`userId` AS `userId`, `tlrs`.`year` AS `year`, `tlrs`.`teacherId` AS `teacherId`, `tlrs`.`reportMonthId` AS `reportMonthId`, `teacher`.`name` AS `teacherName`, `teacher`.`comment` AS `teacherComment`, `rm`.`name` AS `reportMonthName`, CONCAT(COALESCE(`tlrs`.`userId`, \"null\"), \"_\", COALESCE(`tlrs`.`teacherId`, \"null\"), \"_\", COALESCE(`tlrs`.`reportMonthId`, \"null\"), \"_\", COALESCE(`tlrs`.`year`, \"null\")) AS `id`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `reportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `notReportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `reportedLessonNames`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `notReportedLessonNames`, COUNT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonId` END) AS `reportedLessonsCount`, COUNT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END) AS `notReportedLessonsCount`, COUNT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END) > 0 AS `hasNotReportedLessons` FROM `teacher_lesson_report_status` `tlrs` LEFT JOIN `teachers` `teacher` ON `tlrs`.`teacherId` = `teacher`.`id` LEFT JOIN `report_month` `rm` ON `tlrs`.`reportMonthId` = `rm`.`id` GROUP BY `tlrs`.`userId`, `tlrs`.`year`, `tlrs`.`teacherId`, `tlrs`.`reportMonthId` ORDER BY `tlrs`.`reportMonthId` ASC, `tlrs`.`teacherId` ASC"]); + } + + public async down(queryRunner: QueryRunner): Promise { + const dbName = queryRunner.connection.options.database; + await queryRunner.query(` + DELETE FROM \`${dbName}\`.\`typeorm_metadata\` + WHERE \`type\` = ? + AND \`name\` = ? + AND \`schema\` = ? + `, ["VIEW","teacher_report_status",dbName]); + await queryRunner.query(` + DROP VIEW \`teacher_report_status\` + `); + await queryRunner.query(` + DELETE FROM \`${dbName}\`.\`typeorm_metadata\` + WHERE \`type\` = ? + AND \`name\` = ? + AND \`schema\` = ? + `, ["VIEW","teacher_grade_report_status",dbName]); + await queryRunner.query(` + DROP VIEW \`teacher_grade_report_status\` + `); + await queryRunner.query(` + CREATE VIEW \`teacher_grade_report_status\` AS + SELECT \`tlrs\`.\`userId\` AS \`userId\`, + \`tlrs\`.\`year\` AS \`year\`, + \`tlrs\`.\`teacherId\` AS \`teacherId\`, + \`tlrs\`.\`reportMonthId\` AS \`reportMonthId\`, + \`teacher\`.\`name\` AS \`teacherName\`, + \`teacher\`.\`comment\` AS \`teacherComment\`, + \`rm\`.\`name\` AS \`reportMonthName\`, + CONCAT( + COALESCE(\`tlrs\`.\`userId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`teacherId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`reportMonthId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`year\`, "null") + ) AS \`id\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`reportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`notReportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`reportedLessonNames\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`notReportedLessonNames\` + FROM \`teacher_lesson_grade_report_status\` \`tlrs\` + LEFT JOIN \`teachers\` \`teacher\` ON \`tlrs\`.\`teacherId\` = \`teacher\`.\`id\` + LEFT JOIN \`report_month\` \`rm\` ON \`tlrs\`.\`reportMonthId\` = \`rm\`.\`id\` + GROUP BY \`tlrs\`.\`userId\`, + \`tlrs\`.\`teacherId\`, + \`tlrs\`.\`reportMonthId\`, + \`tlrs\`.\`year\` + ORDER BY \`tlrs\`.\`reportMonthId\` ASC, + \`tlrs\`.\`teacherId\` ASC + `); + await queryRunner.query(` + INSERT INTO \`${dbName}\`.\`typeorm_metadata\`( + \`database\`, + \`schema\`, + \`table\`, + \`type\`, + \`name\`, + \`value\` + ) + VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?) + `, [dbName,"VIEW","teacher_grade_report_status","SELECT `tlrs`.`userId` AS `userId`, `tlrs`.`year` AS `year`, `tlrs`.`teacherId` AS `teacherId`, `tlrs`.`reportMonthId` AS `reportMonthId`, `teacher`.`name` AS `teacherName`, `teacher`.`comment` AS `teacherComment`, `rm`.`name` AS `reportMonthName`, CONCAT(COALESCE(`tlrs`.`userId`, \"null\"), \"_\", COALESCE(`tlrs`.`teacherId`, \"null\"), \"_\", COALESCE(`tlrs`.`reportMonthId`, \"null\"), \"_\", COALESCE(`tlrs`.`year`, \"null\")) AS `id`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `reportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `notReportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `reportedLessonNames`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `notReportedLessonNames` FROM `teacher_lesson_grade_report_status` `tlrs` LEFT JOIN `teachers` `teacher` ON `tlrs`.`teacherId` = `teacher`.`id` LEFT JOIN `report_month` `rm` ON `tlrs`.`reportMonthId` = `rm`.`id` GROUP BY `tlrs`.`userId`, `tlrs`.`teacherId`, `tlrs`.`reportMonthId`, `tlrs`.`year` ORDER BY `tlrs`.`reportMonthId` ASC, `tlrs`.`teacherId` ASC"]); + await queryRunner.query(` + CREATE VIEW \`teacher_report_status\` AS + SELECT \`tlrs\`.\`userId\` AS \`userId\`, + \`tlrs\`.\`year\` AS \`year\`, + \`tlrs\`.\`teacherId\` AS \`teacherId\`, + \`tlrs\`.\`reportMonthId\` AS \`reportMonthId\`, + \`teacher\`.\`name\` AS \`teacherName\`, + \`teacher\`.\`comment\` AS \`teacherComment\`, + \`rm\`.\`name\` AS \`reportMonthName\`, + CONCAT( + COALESCE(\`tlrs\`.\`userId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`teacherId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`reportMonthId\`, "null"), + "_", + COALESCE(\`tlrs\`.\`year\`, "null") + ) AS \`id\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`reportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonId\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ',' + ) AS \`notReportedLessons\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 1 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`reportedLessonNames\`, + GROUP_CONCAT( + DISTINCT CASE + WHEN \`tlrs\`.\`isReported\` = 0 THEN \`tlrs\`.\`lessonName\` + END + ORDER BY \`tlrs\`.\`lessonName\` SEPARATOR ', ' + ) AS \`notReportedLessonNames\` + FROM \`teacher_lesson_report_status\` \`tlrs\` + LEFT JOIN \`teachers\` \`teacher\` ON \`tlrs\`.\`teacherId\` = \`teacher\`.\`id\` + LEFT JOIN \`report_month\` \`rm\` ON \`tlrs\`.\`reportMonthId\` = \`rm\`.\`id\` + GROUP BY \`tlrs\`.\`userId\`, + \`tlrs\`.\`year\`, + \`tlrs\`.\`teacherId\`, + \`tlrs\`.\`reportMonthId\` + ORDER BY \`tlrs\`.\`reportMonthId\` ASC, + \`tlrs\`.\`teacherId\` ASC + `); + await queryRunner.query(` + INSERT INTO \`${dbName}\`.\`typeorm_metadata\`( + \`database\`, + \`schema\`, + \`table\`, + \`type\`, + \`name\`, + \`value\` + ) + VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?) + `, [dbName,"VIEW","teacher_report_status","SELECT `tlrs`.`userId` AS `userId`, `tlrs`.`year` AS `year`, `tlrs`.`teacherId` AS `teacherId`, `tlrs`.`reportMonthId` AS `reportMonthId`, `teacher`.`name` AS `teacherName`, `teacher`.`comment` AS `teacherComment`, `rm`.`name` AS `reportMonthName`, CONCAT(COALESCE(`tlrs`.`userId`, \"null\"), \"_\", COALESCE(`tlrs`.`teacherId`, \"null\"), \"_\", COALESCE(`tlrs`.`reportMonthId`, \"null\"), \"_\", COALESCE(`tlrs`.`year`, \"null\")) AS `id`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `reportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonId` END ORDER BY `tlrs`.`lessonName` SEPARATOR ',') AS `notReportedLessons`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 1 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `reportedLessonNames`, GROUP_CONCAT(DISTINCT CASE WHEN `tlrs`.`isReported` = 0 THEN `tlrs`.`lessonName` END ORDER BY `tlrs`.`lessonName` SEPARATOR ', ') AS `notReportedLessonNames` FROM `teacher_lesson_report_status` `tlrs` LEFT JOIN `teachers` `teacher` ON `tlrs`.`teacherId` = `teacher`.`id` LEFT JOIN `report_month` `rm` ON `tlrs`.`reportMonthId` = `rm`.`id` GROUP BY `tlrs`.`userId`, `tlrs`.`year`, `tlrs`.`teacherId`, `tlrs`.`reportMonthId` ORDER BY `tlrs`.`reportMonthId` ASC, `tlrs`.`teacherId` ASC"]); + } + +}