feat(web-ui): sort corroborated halachot first #36

Merged
chaim merged 1 commits from feat/x11-corroborated-first into main 2026-06-01 05:50:29 +00:00

View File

@@ -78,9 +78,21 @@ export function ExtractedHalachotSection({ halachot }: { halachot: Halacha[] })
if (filter === "pending") return h.review_status === "pending_review";
return h.review_status === "rejected";
};
/* Surface citation-corroborated halachot first: any with a badge
* (positive count or a negative treatment) float to the top, ordered
* by corroboration strength; the rest keep document order by index. */
const hasTag = (h: Halacha) =>
(h.corroboration_count ?? 0) > 0 || (h.corroboration_negative ?? false);
return halachot
.filter(matches)
.sort((a, b) => a.halacha_index - b.halacha_index);
.sort((a, b) => {
const tagDelta = Number(hasTag(b)) - Number(hasTag(a));
if (tagDelta !== 0) return tagDelta;
const countDelta =
(b.corroboration_count ?? 0) - (a.corroboration_count ?? 0);
if (countDelta !== 0) return countDelta;
return a.halacha_index - b.halacha_index;
});
}, [halachot, filter]);
if (!halachot.length) {