Merge pull request 'feat(web-ui): sort corroborated halachot first' (#36) from feat/x11-corroborated-first into main
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 36s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 36s
This commit was merged in pull request #36.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user