|
1 |
| -import { capitalize, deburr, startCase } from "lodash-es"; |
2 |
| - |
3 |
| -import type { SIACourse, SIAGroup, uSIAFaculty, uSIAProgram } from "~/functions/src/types/SIA"; |
4 |
| -import type { Course, Group, User } from "~/resources/types/entities"; |
| 1 | +import { deburr } from "lodash-es"; |
5 | 2 | import {
|
6 |
| - eSIAAgrarianScienceBogotaProgram, |
7 |
| - eSIAAgrarianSciencesMedellinProgram, |
8 |
| - eSIAAmazoniaFaculty, |
9 |
| - eSIAAmazoniaProgram, |
10 |
| - eSIAArchitectureMedellinProgram, |
11 |
| - eSIAArtsBogotaProgram, |
| 3 | + type uSIAFaculty, |
| 4 | + type uSIAProgram, |
| 5 | + eSIAPlace, |
12 | 6 | eSIABogotaFaculty,
|
13 | 7 | eSIABogotaProgram,
|
14 |
| - eSIACaribeFaculty, |
15 |
| - eSIACaribeProgram, |
16 |
| - eSIAEconomicalScienceBogotaProgram, |
| 8 | + eSIAMedicineBogotaProgram, |
| 9 | + eSIAVetMedicineBogotaProgram, |
17 | 10 | eSIAEnfermeryBogotaProgram,
|
18 |
| - eSIAEngineeringAndArchitectureManizalesProgram, |
| 11 | + eSIAArtsBogotaProgram, |
19 | 12 | eSIAEngineeringBogotaProgram,
|
20 |
| - eSIAExactSciencesManizalesProgram, |
| 13 | + eSIAOdontologyBogotaProgram, |
| 14 | + eSIALawBogotaProgram, |
| 15 | + eSIAScienceBogotaProgram, |
21 | 16 | eSIAHumanScienceBogotaProgram,
|
22 |
| - eSIAHumanSciencesAMedellinProgram, |
| 17 | + eSIAEconomicalScienceBogotaProgram, |
| 18 | + eSIAAgrarianScienceBogotaProgram, |
23 | 19 | eSIALaPazFaculty,
|
24 | 20 | eSIALaPazProgram,
|
25 |
| - eSIALawBogotaProgram, |
26 |
| - eSIAManagementManizalesProgram, |
27 |
| - eSIAManizalesFaculty, |
28 |
| - eSIAManizalesProgram, |
| 21 | + eSIAPregradoLaPazProgram, |
29 | 22 | eSIAMedellinFaculty,
|
30 | 23 | eSIAMedellinProgram,
|
31 |
| - eSIAMedicineBogotaProgram, |
32 | 24 | eSIAMinesMedellinProgram,
|
33 |
| - eSIAOdontologyBogotaProgram, |
34 |
| - eSIAOrinoquiaFaculty, |
35 |
| - eSIAOrinoquiaProgram, |
| 25 | + eSIAArchitectureMedellinProgram, |
| 26 | + eSIAScienceMedellinProgram, |
| 27 | + eSIAAgrarianSciencesMedellinProgram, |
| 28 | + eSIAHumanSciencesAMedellinProgram, |
| 29 | + eSIAManizalesFaculty, |
| 30 | + eSIAManizalesProgram, |
| 31 | + eSIAEngineeringAndArchitectureManizalesProgram, |
| 32 | + eSIAExactSciencesManizalesProgram, |
| 33 | + eSIAManagementManizalesProgram, |
36 | 34 | eSIAPalmiraFaculty,
|
37 | 35 | eSIAPalmiraProgram,
|
38 |
| - eSIAPlace, |
39 |
| - eSIAPregradoLaPazProgram, |
40 |
| - eSIAScienceBogotaProgram, |
41 |
| - eSIAScienceMedellinProgram, |
| 36 | + eSIAAmazoniaFaculty, |
| 37 | + eSIAAmazoniaProgram, |
| 38 | + eSIACaribeFaculty, |
| 39 | + eSIACaribeProgram, |
| 40 | + eSIAOrinoquiaFaculty, |
| 41 | + eSIAOrinoquiaProgram, |
42 | 42 | eSIATumacoFaculty,
|
43 | 43 | eSIATumacoProgram,
|
44 |
| - eSIATypology, |
45 |
| - eSIAVetMedicineBogotaProgram, |
46 |
| -} from "~/functions/src/types/SIA/enums"; |
47 |
| -import { isNotUndefString } from "~/resources/utils/guards"; |
48 |
| -import { Cyrb53 } from "~/resources/utils/firestore"; |
| 44 | +} from "~/functions/src/types/SIA"; |
| 45 | + |
| 46 | +import type { Course, User } from "~/resources/types/entities"; |
49 | 47 |
|
50 | 48 | interface UNALItem {
|
51 | 49 | faculty: uSIAFaculty;
|
52 | 50 | programs: uSIAProgram[];
|
53 | 51 | }
|
54 | 52 |
|
55 |
| -const UNAL: Record<eSIAPlace, UNALItem[]> = { |
| 53 | +export const UNAL: Record<eSIAPlace, UNALItem[]> = { |
56 | 54 | [eSIAPlace.BOGOTÁ]: [
|
57 | 55 | {
|
58 | 56 | faculty: eSIABogotaFaculty.SEDE_BOGOTÁ,
|
@@ -202,112 +200,6 @@ export function useMapUser({ role = 3, ...user }: User) {
|
202 | 200 | return { ...user, role: roleName };
|
203 | 201 | }
|
204 | 202 |
|
205 |
| -export function useMapGroupFromBETA(source: SIAGroup): Group { |
206 |
| - const programsString = source.PLANES_ASOCIADOS || ""; |
207 |
| - const [, ...programs] = programsString.split("*** Plan:").map((p) => <uSIAProgram>p.trim()); |
208 |
| - |
209 |
| - return { |
210 |
| - SIA: source.ID, |
211 |
| - name: source.GRUPO, |
212 |
| - spots: source.CUPOS, |
213 |
| - schedule: [ |
214 |
| - source.HORARIO_LUNES, |
215 |
| - source.HORARIO_MARTES, |
216 |
| - source.HORARIO_MIERCOLES, |
217 |
| - source.HORARIO_JUEVES, |
218 |
| - source.HORARIO_VIERNES, |
219 |
| - source.HORARIO_SABADO, |
220 |
| - source.HORARIO_DOMINGO, |
221 |
| - ], |
222 |
| - teachers: [startCase(source.DOCENTE.toLowerCase())], |
223 |
| - activity: source.ACTIVIDAD, |
224 |
| - availableSpots: source.CUPOS_DISPONIBLES, |
225 |
| - classrooms: [source.AULA], |
226 |
| - period: source.PERIODO, |
227 |
| - programs, |
228 |
| - }; |
229 |
| -} |
230 |
| - |
231 |
| -/** |
232 |
| - * Map course from SIA beta |
233 |
| - */ |
234 |
| -export function useMapCourseFromExplorerV1(source: SIACourse): Course { |
235 |
| - // Generate deduped course UID |
236 |
| - const id = `courses/${Cyrb53([source.CODIGO_ASIGNATURA])}`; |
237 |
| - const groups: Group[] = []; |
238 |
| - const typology = source.TIPOLOGIA; |
239 |
| - const place = source.SEDE; |
240 |
| - let faculty = source.FACULTAD; |
241 |
| - let faculties = [faculty]; |
242 |
| - let programs = source.PLANDEESTUDIO ? [source.PLANDEESTUDIO] : []; |
243 |
| - |
244 |
| - // Dedupe groups |
245 |
| - source.DETALLECURSOASIGNATURA.forEach((groupBETA) => { |
246 |
| - const group = useMapGroupFromBETA(groupBETA); |
247 |
| - // Groups can be duplicated diff(teacher, schedule, classroom) |
248 |
| - const groupIndex = groups.findIndex(({ name }) => name === group.name); |
249 |
| - |
250 |
| - // Index group |
251 |
| - if (groupIndex === -1) { |
252 |
| - // Assign one of the associated programs |
253 |
| - // Some global LE programs do not have an associated program and are hard to find on old SIA |
254 |
| - if (!programs.length && typology === eSIATypology.LIBRE_ELECCIÓN) { |
255 |
| - const [program] = group.programs || []; |
256 |
| - const associatedFaculty = UNAL[place].find((f) => f.programs.includes(program)); |
257 |
| - |
258 |
| - if (!associatedFaculty) return groups.push(group); |
259 |
| - |
260 |
| - faculty = associatedFaculty.faculty; |
261 |
| - faculties = [faculty]; |
262 |
| - programs = [program]; |
263 |
| - } |
264 |
| - |
265 |
| - return groups.push(group); |
266 |
| - } |
267 |
| - |
268 |
| - const currentSchedule = groups[groupIndex]?.schedule || []; |
269 |
| - const newSchedule = group.schedule || []; |
270 |
| - const uniqueClassrooms = [ |
271 |
| - ...new Set([groups[groupIndex].classrooms, group.classrooms].flat()), |
272 |
| - ].filter(isNotUndefString); |
273 |
| - const uniqueTeachers = [ |
274 |
| - ...new Set([groups[groupIndex].teachers, group.teachers].flat()), |
275 |
| - ].filter(isNotUndefString); |
276 |
| - |
277 |
| - // Complement existing group data |
278 |
| - groups[groupIndex].classrooms = uniqueClassrooms; |
279 |
| - groups[groupIndex].teachers = uniqueTeachers; |
280 |
| - groups[groupIndex].schedule = [ |
281 |
| - currentSchedule[0] || newSchedule[0], // monday |
282 |
| - currentSchedule[1] || newSchedule[1], // tuesday |
283 |
| - currentSchedule[2] || newSchedule[2], // wednesday |
284 |
| - currentSchedule[3] || newSchedule[3], // thursday |
285 |
| - currentSchedule[4] || newSchedule[4], // friday |
286 |
| - currentSchedule[5] || newSchedule[5], // saturday |
287 |
| - currentSchedule[6] || newSchedule[6], // sunday |
288 |
| - ]; |
289 |
| - }); |
290 |
| - |
291 |
| - const spotsCount = groups.reduce((sum, { availableSpots = 0 }) => sum + availableSpots, 0); |
292 |
| - |
293 |
| - return { |
294 |
| - id, |
295 |
| - SIA: source.IDBUSCADORCURSO, |
296 |
| - name: capitalize(source.NOMBREASIGNATURA), |
297 |
| - alternativeNames: [source.NOMBREASIGNATURA], |
298 |
| - code: source.CODIGO_ASIGNATURA, |
299 |
| - credits: source.NUM_CREDITOS, |
300 |
| - typologies: [typology], |
301 |
| - level: source.NIVELDEESTUDIO, |
302 |
| - place, |
303 |
| - faculty, |
304 |
| - faculties, |
305 |
| - programs, |
306 |
| - groups, |
307 |
| - spotsCount, |
308 |
| - }; |
309 |
| -} |
310 |
| - |
311 | 203 | export function useMapCourse({ groups = [], ...course }: Course): Course {
|
312 | 204 | const SESSION = useSessionStore();
|
313 | 205 | const [, placeOnly] = deburr(SESSION.place).toLowerCase().replace(" de la", "").split("sede ");
|
|
0 commit comments