Skip to content

Commit 59fa63f

Browse files
committed
use filterCourse ID to label results
1 parent 3628677 commit 59fa63f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packages/common-ui/src/components/CardSearchResults.vue

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,36 @@ export default defineComponent({
6868
this.loading = true;
6969
this.error = null;
7070
try {
71-
const coursesDB = this.dataLayer.getCoursesDB();
72-
let courses = await coursesDB.getCourseList();
71+
let courseIds: string[] = [];
7372
74-
// Apply course filter if specified
73+
// Get course IDs efficiently
7574
if (this.courseFilter) {
76-
courses = courses.filter(course => course.courseID === this.courseFilter);
75+
// Single course search - no need to fetch all courses
76+
courseIds = [this.courseFilter];
7777
console.log(`Filtering search to course: ${this.courseFilter}`);
7878
} else {
79-
console.log(`Searching across all ${courses.length} courses`);
79+
// Get all course IDs without expensive config lookups
80+
const { CourseLookup } = await import('@vue-skuilder/db');
81+
const lookupCourses = await CourseLookup.allCourseWare();
82+
courseIds = lookupCourses.map(c => c._id).filter(Boolean);
83+
console.log(`Searching across all ${courseIds.length} courses`);
8084
}
8185
8286
const allCards: CardWithCourse[] = [];
8387
84-
for (const course of courses) {
85-
if (!course.courseID) continue;
86-
87-
const courseDB = this.dataLayer.getCourseDB(course.courseID);
88+
for (const courseId of courseIds) {
89+
const courseDB = this.dataLayer.getCourseDB(courseId);
8890
const cards = await courseDB.searchCards(query);
8991
9092
for (const card of cards) {
9193
allCards.push({
9294
...card,
93-
courseId: course.courseID,
95+
courseId: courseId,
9496
});
9597
}
9698
}
9799
this.cards = allCards;
98-
console.log(`Search completed: found ${allCards.length} cards across ${courses.length} courses`);
100+
console.log(`Search completed: found ${allCards.length} cards across ${courseIds.length} courses`);
99101
} catch (e) {
100102
this.error = 'Error fetching search results.';
101103
console.error('Search error:', e);

0 commit comments

Comments
 (0)