Skip to content

Commit 4d965d3

Browse files
committed
Merge branch 'dev'
2 parents ec7bc40 + 5195986 commit 4d965d3

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

composables/inputs/courses.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export function useCourseInputs(course: Course = {}): FormInput[] {
1616
const { typologies } = useCourseTypeOptions();
1717
const facultyInput = new FormInput(
1818
{
19-
values: [course?.faculty || fixCourse ? <uSIAFaculty>"" : SESSION.lastFacultySearch],
19+
values: [
20+
course?.faculty || fixCourse
21+
? <uSIAFaculty>faculties.value[0].value
22+
: SESSION.lastFacultySearch,
23+
],
2024
name: "faculty",
2125
required: true,
2226
title: "Facultad del curso (Sede Bogotá)",
@@ -42,13 +46,18 @@ export function useCourseInputs(course: Course = {}): FormInput[] {
4246
}
4347
);
4448
const programInput = new FormInput({
45-
values: [course?.program || fixCourse ? <uSIAProgram>"" : SESSION.lastProgramSearch],
49+
values: [
50+
course?.program || fixCourse
51+
? <uSIAProgram>programs.value[0].value
52+
: SESSION.lastProgramSearch,
53+
],
4654
name: "program",
4755
title: "Programa del curso (Sede Bogotá)",
4856
placeholder: "Ej: Ciencias de la computación",
4957
options: programs.value,
5058
type: eFormType.SELECT,
5159
icon: "chess-rook",
60+
required: fixCourse,
5261
});
5362

5463
const inputs: FormInput[] = [

pages/cursos/[courseId].vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
Aunque el curso esta reportado, su información parece ser inadecuada
3232
y no nos permite encontrarlo en el SIA.
3333
</p>
34+
<p class="--txtSize-sm">
35+
Es posible que no sea ofertada este semestre.
36+
</p>
3437
</div>
3538
</XamuBoxMessage>
3639
</div>
@@ -255,7 +258,7 @@
255258

256259
<script setup lang="ts">
257260
import { debounce } from "lodash-es";
258-
import { arrayUnion, doc, onSnapshot, type Unsubscribe } from "firebase/firestore";
261+
import { arrayUnion, deleteField, doc, onSnapshot, type Unsubscribe } from "firebase/firestore";
259262
import { FirebaseError } from "firebase/app";
260263
261264
import type { iInvalidInput, iPageEdge } from "@open-xamu-co/ui-common-types";
@@ -524,30 +527,28 @@
524527
if (!course.value) return { data: null };
525528
526529
try {
527-
// update course
528-
const data = await useDocumentUpdate<Course>(course.value, {
529-
typologies: [typology],
530+
// Update course, do not await
531+
useDocumentUpdate<Course>(course.value, {
532+
typologies: typology ? [typology] : deleteField(),
530533
faculty,
531534
faculties: [faculty],
532535
programs: [program],
533536
});
534537
535-
if (!data) return { data: null };
536-
537538
const minutes = APP.instance?.config?.coursesScrapeRate || 5;
538539
const nowMilis = new Date().getTime();
539540
const scrapedAtMilis = new Date(course.value.scrapedAt || "").getTime();
540541
const scrapedDiffMilis = nowMilis - scrapedAtMilis;
541542
542543
// Do once & update if updated more than threshold
543544
if (scrapedDiffMilis < useMinMilis(minutes)) {
544-
if (course.value.description) return { data };
545+
if (course.value.description) return { data: false };
545546
}
546547
547548
// Atemp course scraping
548549
await scrapeCourse(course.value);
549550
550-
return { data };
551+
return { data: true };
551552
} catch (errors: FirebaseError | unknown) {
552553
return { errors };
553554
}

server/api/groups/scrape.get.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ export default defineConditionallyCachedEventHandler(async (event, instance, aut
196196
let faculties: uSIAFaculty[] = Array.isArray(params.faculties)
197197
? params.faculties
198198
: [params.faculties];
199-
let programs: uSIAProgram[] = Array.isArray(params.programs)
199+
const programs: uSIAProgram[] = Array.isArray(params.programs)
200200
? params.programs
201201
: [params.programs];
202202
let typologies: eSIATypology[] = Array.isArray(params.typologies)
203203
? params.typologies
204204
: [params.typologies];
205-
const LEByProgram = !programs[0];
205+
const LEByProgram = !programs[0] || typologies.includes(eSIATypology.LIBRE_ELECCIÓN);
206206
const LEByFaculty = !faculties[0];
207207

208208
// Override data if missing, assume LE
@@ -212,47 +212,47 @@ export default defineConditionallyCachedEventHandler(async (event, instance, aut
212212
switch (place) {
213213
case eSIAPlace.BOGOTÁ:
214214
if (LEByFaculty) faculties = [eSIABogotaFaculty.SEDE_BOGOTÁ];
215-
if (LEByProgram) programs = [eSIABogotaProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
215+
if (LEByProgram) programs.push(eSIABogotaProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
216216

217217
break;
218218
case eSIAPlace.LA_PAZ:
219219
if (LEByFaculty) faculties = [eSIALaPazFaculty.SEDE_LA_PAZ];
220-
if (LEByProgram) programs = [eSIALaPazProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
220+
if (LEByProgram) programs.push(eSIALaPazProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
221221

222222
break;
223223
case eSIAPlace.MEDELLÍN:
224224
if (LEByFaculty) faculties = [eSIAMedellinFaculty.SEDE_MEDELLÍN];
225-
if (LEByProgram) programs = [eSIAMedellinProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
225+
if (LEByProgram) programs.push(eSIAMedellinProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
226226

227227
break;
228228
case eSIAPlace.MANIZALES:
229229
if (LEByFaculty) faculties = [eSIAManizalesFaculty.SEDE_MANIZALES];
230-
if (LEByProgram) programs = [eSIAManizalesProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
230+
if (LEByProgram) programs.push(eSIAManizalesProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
231231

232232
break;
233233
case eSIAPlace.PALMIRA:
234234
if (LEByFaculty) faculties = [eSIAPalmiraFaculty.SEDE_PALMIRA];
235-
if (LEByProgram) programs = [eSIAPalmiraProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
235+
if (LEByProgram) programs.push(eSIAPalmiraProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
236236

237237
break;
238238
case eSIAPlace.TUMACO:
239239
if (LEByFaculty) faculties = [eSIATumacoFaculty.SEDE_TUMACO];
240-
if (LEByProgram) programs = [eSIATumacoProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
240+
if (LEByProgram) programs.push(eSIATumacoProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
241241

242242
break;
243243
case eSIAPlace.AMAZONÍA:
244244
if (LEByFaculty) faculties = [eSIAAmazoniaFaculty.SEDE_AMAZONIA];
245-
if (LEByProgram) programs = [eSIAAmazoniaProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
245+
if (LEByProgram) programs.push(eSIAAmazoniaProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
246246

247247
break;
248248
case eSIAPlace.CARIBE:
249249
if (LEByFaculty) faculties = [eSIACaribeFaculty.SEDE_CARIBE];
250-
if (LEByProgram) programs = [eSIACaribeProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
250+
if (LEByProgram) programs.push(eSIACaribeProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
251251

252252
break;
253253
case eSIAPlace.ORINOQUÍA:
254254
if (LEByFaculty) faculties = [eSIAOrinoquiaFaculty.SEDE_ORINOQUIA];
255-
if (LEByProgram) programs = [eSIAOrinoquiaProgram.COMPONENTE_DE_LIBRE_ELECCIÓN];
255+
if (LEByProgram) programs.push(eSIAOrinoquiaProgram.COMPONENTE_DE_LIBRE_ELECCIÓN);
256256

257257
break;
258258
}

0 commit comments

Comments
 (0)