mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +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'}"
|
||||
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'}">
|
||||
{item.metadata?.type === 'assessments' ? '\ueac3' : '\ueb4d'}
|
||||
</div>
|
||||
|
||||
@@ -25,12 +25,10 @@ export const subjectsJob: Job = {
|
||||
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
|
||||
console.log("active subject:", item.metadata.subjectName);
|
||||
} else {
|
||||
console.log("inactive subject:", item.metadata.subjectName);
|
||||
score -= 50; // Penalty for inactive subjects
|
||||
}
|
||||
|
||||
return score;
|
||||
@@ -83,8 +81,7 @@ export const subjectsJob: Job = {
|
||||
const isActive = semester.active === 1;
|
||||
|
||||
// Create two items for each subject - one for assessments and one for course
|
||||
items.push(
|
||||
{
|
||||
const assessmentsItem = {
|
||||
id: `${id}-assessments`,
|
||||
text: `${subject.title} Assessments`,
|
||||
category: "subjects",
|
||||
@@ -102,8 +99,9 @@ export const subjectsJob: Job = {
|
||||
},
|
||||
actionId: "subjectassessment",
|
||||
renderComponentId: "subject",
|
||||
},
|
||||
{
|
||||
};
|
||||
|
||||
const courseItem = {
|
||||
id: `${id}-course`,
|
||||
text: `${subject.title} Course`,
|
||||
category: "subjects",
|
||||
@@ -121,7 +119,15 @@ export const subjectsJob: Job = {
|
||||
},
|
||||
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
|
||||
dynamicResults.forEach((r) => {
|
||||
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);
|
||||
if (vectorMatch) {
|
||||
// If we found it in both searches, combine the scores
|
||||
|
||||
Reference in New Issue
Block a user