mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
feat: boosted active subjects + visual indication of inactive subjects
This commit is contained in:
@@ -17,7 +17,7 @@ import type { IndexItem } from '../../indexing/types';
|
|||||||
{isSelected ? 'bg-zinc-900/5 dark:bg-white/10 text-zinc-900 dark:text-white' : 'hover:bg-zinc-500/5 dark:hover:bg-white/5 text-zinc-800 dark:text-zinc-200'}"
|
{isSelected ? 'bg-zinc-900/5 dark:bg-white/10 text-zinc-900 dark:text-white' : 'hover:bg-zinc-500/5 dark:hover:bg-white/5 text-zinc-800 dark:text-zinc-200'}"
|
||||||
onclick={onclick}
|
onclick={onclick}
|
||||||
>
|
>
|
||||||
<div class="flex items-center w-full">
|
<div class="flex items-center w-full {item.metadata.isActive ? 'opacity-100' : 'opacity-70'}">
|
||||||
<div class="flex-none w-8 h-8 text-xl font-IconFamily flex items-center justify-center {isSelected ? 'text-zinc-900 dark:text-white' : 'text-zinc-600 dark:text-zinc-400'}">
|
<div class="flex-none w-8 h-8 text-xl font-IconFamily flex items-center justify-center {isSelected ? 'text-zinc-900 dark:text-white' : 'text-zinc-600 dark:text-zinc-400'}">
|
||||||
{item.metadata?.type === 'assessments' ? '\ueac3' : '\ueb4d'}
|
{item.metadata?.type === 'assessments' ? '\ueac3' : '\ueb4d'}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,12 +25,10 @@ export const subjectsJob: Job = {
|
|||||||
score += 20; // Boost score for direct subject matches
|
score += 20; // Boost score for direct subject matches
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boost for active subjects
|
if (item.metadata.isActive) {
|
||||||
if (item.metadata?.isActive) {
|
|
||||||
score += 15; // Boost for active subjects
|
score += 15; // Boost for active subjects
|
||||||
console.log("active subject:", item.metadata.subjectName);
|
|
||||||
} else {
|
} else {
|
||||||
console.log("inactive subject:", item.metadata.subjectName);
|
score -= 50; // Penalty for inactive subjects
|
||||||
}
|
}
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
@@ -83,45 +81,53 @@ export const subjectsJob: Job = {
|
|||||||
const isActive = semester.active === 1;
|
const isActive = semester.active === 1;
|
||||||
|
|
||||||
// Create two items for each subject - one for assessments and one for course
|
// Create two items for each subject - one for assessments and one for course
|
||||||
items.push(
|
const assessmentsItem = {
|
||||||
{
|
id: `${id}-assessments`,
|
||||||
id: `${id}-assessments`,
|
text: `${subject.title} Assessments`,
|
||||||
text: `${subject.title} Assessments`,
|
category: "subjects",
|
||||||
category: "subjects",
|
content: `View assessments for ${subject.title} (${semester.description})`,
|
||||||
content: `View assessments for ${subject.title} (${semester.description})`,
|
dateAdded: Date.now(),
|
||||||
dateAdded: Date.now(),
|
metadata: {
|
||||||
metadata: {
|
subjectId: subject.metaclass,
|
||||||
subjectId: subject.metaclass,
|
subjectName: subject.title,
|
||||||
subjectName: subject.title,
|
subjectCode: subject.code,
|
||||||
subjectCode: subject.code,
|
programme: subject.programme,
|
||||||
programme: subject.programme,
|
semesterCode: semester.code,
|
||||||
semesterCode: semester.code,
|
semesterDescription: semester.description,
|
||||||
semesterDescription: semester.description,
|
type: "assessments",
|
||||||
type: "assessments",
|
isActive
|
||||||
isActive
|
|
||||||
},
|
|
||||||
actionId: "subjectassessment",
|
|
||||||
renderComponentId: "subject",
|
|
||||||
},
|
},
|
||||||
{
|
actionId: "subjectassessment",
|
||||||
id: `${id}-course`,
|
renderComponentId: "subject",
|
||||||
text: `${subject.title} Course`,
|
};
|
||||||
category: "subjects",
|
|
||||||
content: `View course content for ${subject.title} (${semester.description})`,
|
const courseItem = {
|
||||||
dateAdded: Date.now(),
|
id: `${id}-course`,
|
||||||
metadata: {
|
text: `${subject.title} Course`,
|
||||||
subjectId: subject.metaclass,
|
category: "subjects",
|
||||||
subjectName: subject.title,
|
content: `View course content for ${subject.title} (${semester.description})`,
|
||||||
subjectCode: subject.code,
|
dateAdded: Date.now(),
|
||||||
programme: subject.programme,
|
metadata: {
|
||||||
semesterCode: semester.code,
|
subjectId: subject.metaclass,
|
||||||
semesterDescription: semester.description,
|
subjectName: subject.title,
|
||||||
type: "course",
|
subjectCode: subject.code,
|
||||||
isActive
|
programme: subject.programme,
|
||||||
},
|
semesterCode: semester.code,
|
||||||
actionId: "subjectcourse",
|
semesterDescription: semester.description,
|
||||||
renderComponentId: "subject",
|
type: "course",
|
||||||
}
|
isActive
|
||||||
|
},
|
||||||
|
actionId: "subjectcourse",
|
||||||
|
renderComponentId: "subject",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Log all subject items during indexing
|
||||||
|
console.log('Indexing subject:', assessmentsItem.text, assessmentsItem.metadata.isActive);
|
||||||
|
console.log('Indexing subject:', courseItem.text, courseItem.metadata.isActive);
|
||||||
|
|
||||||
|
items.push(
|
||||||
|
assessmentsItem,
|
||||||
|
courseItem
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,18 @@ export async function performSearch(
|
|||||||
// Add dynamic results first
|
// Add dynamic results first
|
||||||
dynamicResults.forEach((r) => {
|
dynamicResults.forEach((r) => {
|
||||||
seenIds.add(r.id);
|
seenIds.add(r.id);
|
||||||
|
|
||||||
|
if (r.type === "dynamic") {
|
||||||
|
const dynamicItem = r.item as IndexItem;
|
||||||
|
const job = jobs[dynamicItem.category];
|
||||||
|
if (job && typeof job.boostCriteria === 'function') {
|
||||||
|
const boost = job.boostCriteria(dynamicItem, query);
|
||||||
|
if (boost) {
|
||||||
|
r.score += boost; // Add the boost to the score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vectorMatch = vectorResults.find((v) => v.object.id === r.id);
|
const vectorMatch = vectorResults.find((v) => v.object.id === r.id);
|
||||||
if (vectorMatch) {
|
if (vectorMatch) {
|
||||||
// If we found it in both searches, combine the scores
|
// If we found it in both searches, combine the scores
|
||||||
|
|||||||
Reference in New Issue
Block a user