-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only Available subdivisions shown; Fixed typescript build errors;
- Loading branch information
1 parent
e992d9b
commit cbdcaaf
Showing
14 changed files
with
167 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Subdivision } from "../database"; | ||
|
||
export default async function availableSubdivisions(slotId: number, divisionId: number) { | ||
const subdivisions = await Subdivision.findAll({ | ||
where: { DivisionId: divisionId }, | ||
}); | ||
const subdivisionIds = subdivisions.map((subdivision) => subdivision.id); | ||
const busySubdivisions = await Subdivision.findAll({ | ||
include: [ | ||
{ | ||
association: "SlotDataSubdivisions", | ||
where: { SubdivisionId: subdivisionIds }, | ||
required: true, | ||
attributes: [], | ||
include: [ | ||
{ | ||
association: "SlotData", | ||
where: { SlotId: slotId }, | ||
required: true, | ||
attributes: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
const availableSubdivisions = subdivisions.filter( | ||
(availableSubdivision) => | ||
!busySubdivisions.some((busySubdivision) => busySubdivision.id === availableSubdivision.id), | ||
); | ||
return availableSubdivisions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
import { Subject, Teacher } from "../database"; | ||
import {getSubjectTeachers} from "./"; | ||
import { Teacher } from "../database"; | ||
import { getSubjectTeachers } from "./"; | ||
|
||
async function getAvailableTeachers(slotId: number, subjectId: number) { | ||
const subjectTeachers = await getSubjectTeachers(subjectId); | ||
const subject = await Subject.findByPk(subjectId); | ||
console.log(subject?.toJSON()) | ||
// Busy teachers in the given slot | ||
const busyTeachers = await Teacher.findAll({ | ||
include: [ | ||
{ | ||
association: "SlotDatas", | ||
where: { slotId: slotId, subjectId: subjectId}, | ||
where: { slotId: slotId, subjectId: subjectId }, | ||
required: true, | ||
include: [{ | ||
association: "SlotDataSubdivisions", | ||
required: true, | ||
attributes: [], | ||
}] | ||
include: [ | ||
{ | ||
association: "SlotDataSubdivisions", | ||
required: true, | ||
attributes: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
const availableSubjectTeachers = subjectTeachers.filter( | ||
(subjectTeacher) => !busyTeachers.some((teacher) => teacher.id === subjectTeacher.id) | ||
(subjectTeacher) => !busyTeachers.some((teacher) => teacher.id === subjectTeacher.id), | ||
); | ||
console.log(busyTeachers.length) | ||
console.log(availableSubjectTeachers.length) | ||
|
||
return availableSubjectTeachers; | ||
} | ||
|
||
await getAvailableTeachers(21, 1) | ||
|
||
export default getAvailableTeachers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.