Skip to content

Commit d9cdc4a

Browse files
committed
Merge branch 'dev'
2 parents 434cfef + 876a78c commit d9cdc4a

File tree

16 files changed

+681
-284
lines changed

16 files changed

+681
-284
lines changed

app.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<div
103103
class="flx --flxRow --flx-center --gap-10 --txtSize-xs"
104104
>
105-
<template v-if="APP.instance?.config?.version">
105+
<template v-if="APP.config?.version">
106106
<span>{{ APP.instance.config.version }}</span>
107107
108108
</template>
@@ -127,9 +127,7 @@
127127
</p>
128128
<p
129129
class="--txtSize-xs --txtColor-dark5"
130-
:title="
131-
APP.instance?.config?.siaMaintenanceTillAt?.toString()
132-
"
130+
:title="APP.config?.siaMaintenanceTillAt?.toString()"
133131
>
134132
Volveremos a la normalidad {{ SIAMaintenanceTillAt }}.
135133
</p>
@@ -194,17 +192,17 @@
194192

195193
const isAdmin = computed(() => route.path.startsWith("/administrar"));
196194
const SIAMaintenanceTillAt = computed(() => {
197-
const date = new Date(APP.instance?.config?.siaMaintenanceTillAt || new Date());
195+
const date = new Date(APP.config?.siaMaintenanceTillAt || new Date());
198196

199197
return useTimeAgo(date);
200198
});
201199
const ExplorerV1MaintenanceTillAt = computed(() => {
202-
const date = new Date(APP.instance?.config?.explorerV1MaintenanceTillAt || new Date());
200+
const date = new Date(APP.config?.explorerV1MaintenanceTillAt || new Date());
203201

204202
return useTimeAgo(date);
205203
});
206204
const ExplorerV2MaintenanceTillAt = computed(() => {
207-
const date = new Date(APP.instance?.config?.explorerV2MaintenanceTillAt || new Date());
205+
const date = new Date(APP.config?.explorerV2MaintenanceTillAt || new Date());
208206

209207
return useTimeAgo(date);
210208
});

components/searchCourse.vue

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<div class="txt">
1515
<div>
1616
<h3>
17-
Resultados de la busqueda
17+
Resultados de la búsqueda
1818
<template v-if="lastSearch?.name || lastSearch?.code">
1919
de "{{ lastSearch?.name || lastSearch?.code }}"
2020
</template>
2121
:
2222
</h3>
23-
<p class="--txtSize-xs">Datos obtenidos del buscador del SIA (Beta).</p>
23+
<p class="--txtSize-xs">Datos obtenidos del explorador de cursos.</p>
2424
</div>
2525
<p>
2626
{{ untrackedCurrentPage.totalRecords }} resultados. Pagina
@@ -125,11 +125,7 @@
125125
import { XamuBaseAction } from "#components";
126126
import type { Course } from "~/resources/types/entities";
127127
import type { CourseValues } from "~/resources/types/values";
128-
import {
129-
eSIATypology,
130-
type CoursesResponse,
131-
type uSIAProgram,
132-
} from "~/functions/src/types/SIA";
128+
import { type CoursesResponse } from "~/functions/src/types/SIA";
133129
import { getDocumentId } from "~/resources/utils/firestore";
134130

135131
/**
@@ -178,55 +174,16 @@
178174
errors.value = undefined;
179175

180176
try {
181-
const coursesPage = await useExplorerV1Courses(
182-
props.values,
183-
untrackedCurrentPage.value?.currentPage
184-
);
185-
const codes: string[] = [];
186-
const dedupedCourses: Course[] = [];
187-
188-
/**
189-
* Remove duplicates & omit courses without groups
190-
* The system return entities with the same data but differing in the internal id
191-
*/
192-
coursesPage.data.forEach(({ faculties = [], ...course }) => {
193-
if (!course.code || !course.groups?.length) return;
194-
195-
const dedupedCourseIndex = dedupedCourses.findIndex(({ id }) => id === course.id);
196-
197-
if (dedupedCourseIndex >= 0) {
198-
// merge details
199-
const dedupedCourse = dedupedCourses[dedupedCourseIndex];
200-
const uniquePrograms = [
201-
...new Set([dedupedCourse.programs, course.programs].flat()),
202-
].filter((p: uSIAProgram | undefined): p is uSIAProgram => !!p);
203-
const uniqueTypologies = [
204-
...new Set([dedupedCourse.typologies, course.typologies].flat()),
205-
].filter((p: eSIATypology | undefined): p is eSIATypology => !!p);
206-
207-
dedupedCourses[dedupedCourseIndex].programs = uniquePrograms;
208-
dedupedCourses[dedupedCourseIndex].typologies = uniqueTypologies;
209-
210-
return;
211-
}
212-
213-
// Inject faculty, that helped in search
214-
if (props.values.faculty && !faculties.includes(props.values.faculty)) {
215-
faculties.push(props.values.faculty);
216-
}
217-
218-
codes.push(course.code);
219-
dedupedCourses.push({ ...course, faculties });
220-
});
177+
const coursesPage = await useExplorerV2Courses(props.values);
221178

222179
// Refresh UI
223180
lastSearch.value = { ...props.values, page: coursesPage.currentPage };
224-
untrackedCourses.value = dedupedCourses;
181+
untrackedCourses.value = coursesPage.data;
225182
untrackedCurrentPage.value = coursesPage;
226-
savedUntrackedCourses.value[coursesPage.currentPage] = dedupedCourses;
183+
savedUntrackedCourses.value[coursesPage.currentPage] = coursesPage.data;
227184

228185
// Index course, do not await
229-
indexCourses(dedupedCourses, coursesPage);
186+
indexCourses(coursesPage.data, coursesPage);
230187
} catch (err) {
231188
useLogger("components:SearchCourse", err);
232189
errors.value = err;

components/table/TeacherItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
const Swal = useSwal();
7070

7171
const losEstudiantesProfessors = computed(() => {
72-
const config = APP.instance?.config || {};
72+
const config = APP.config || {};
7373
const { losEstudiantesUrl = "", losEstudiantesProfessorsPath = "" } = config;
7474

7575
return `${losEstudiantesUrl}${losEstudiantesProfessorsPath}`;

composables/data.ts

Lines changed: 32 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,56 @@
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";
52
import {
6-
eSIAAgrarianScienceBogotaProgram,
7-
eSIAAgrarianSciencesMedellinProgram,
8-
eSIAAmazoniaFaculty,
9-
eSIAAmazoniaProgram,
10-
eSIAArchitectureMedellinProgram,
11-
eSIAArtsBogotaProgram,
3+
type uSIAFaculty,
4+
type uSIAProgram,
5+
eSIAPlace,
126
eSIABogotaFaculty,
137
eSIABogotaProgram,
14-
eSIACaribeFaculty,
15-
eSIACaribeProgram,
16-
eSIAEconomicalScienceBogotaProgram,
8+
eSIAMedicineBogotaProgram,
9+
eSIAVetMedicineBogotaProgram,
1710
eSIAEnfermeryBogotaProgram,
18-
eSIAEngineeringAndArchitectureManizalesProgram,
11+
eSIAArtsBogotaProgram,
1912
eSIAEngineeringBogotaProgram,
20-
eSIAExactSciencesManizalesProgram,
13+
eSIAOdontologyBogotaProgram,
14+
eSIALawBogotaProgram,
15+
eSIAScienceBogotaProgram,
2116
eSIAHumanScienceBogotaProgram,
22-
eSIAHumanSciencesAMedellinProgram,
17+
eSIAEconomicalScienceBogotaProgram,
18+
eSIAAgrarianScienceBogotaProgram,
2319
eSIALaPazFaculty,
2420
eSIALaPazProgram,
25-
eSIALawBogotaProgram,
26-
eSIAManagementManizalesProgram,
27-
eSIAManizalesFaculty,
28-
eSIAManizalesProgram,
21+
eSIAPregradoLaPazProgram,
2922
eSIAMedellinFaculty,
3023
eSIAMedellinProgram,
31-
eSIAMedicineBogotaProgram,
3224
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,
3634
eSIAPalmiraFaculty,
3735
eSIAPalmiraProgram,
38-
eSIAPlace,
39-
eSIAPregradoLaPazProgram,
40-
eSIAScienceBogotaProgram,
41-
eSIAScienceMedellinProgram,
36+
eSIAAmazoniaFaculty,
37+
eSIAAmazoniaProgram,
38+
eSIACaribeFaculty,
39+
eSIACaribeProgram,
40+
eSIAOrinoquiaFaculty,
41+
eSIAOrinoquiaProgram,
4242
eSIATumacoFaculty,
4343
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";
4947

5048
interface UNALItem {
5149
faculty: uSIAFaculty;
5250
programs: uSIAProgram[];
5351
}
5452

55-
const UNAL: Record<eSIAPlace, UNALItem[]> = {
53+
export const UNAL: Record<eSIAPlace, UNALItem[]> = {
5654
[eSIAPlace.BOGOTÁ]: [
5755
{
5856
faculty: eSIABogotaFaculty.SEDE_BOGOTÁ,
@@ -202,112 +200,6 @@ export function useMapUser({ role = 3, ...user }: User) {
202200
return { ...user, role: roleName };
203201
}
204202

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-
311203
export function useMapCourse({ groups = [], ...course }: Course): Course {
312204
const SESSION = useSessionStore();
313205
const [, placeOnly] = deburr(SESSION.place).toLowerCase().replace(" de la", "").split("sede ");

0 commit comments

Comments
 (0)