Merge pull request 'feat(halacha-triage UI): wire gating + near-duplicate cluster cards (#84.2)' (#98) from worktree-task84.2-ui-clustering into main
Some checks failed
Build & Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build & Deploy / build-and-deploy (push) Has been cancelled
This commit was merged in pull request #98.
This commit is contained in:
@@ -92,6 +92,11 @@ export type Halacha = {
|
||||
* negatively (distinguished/criticized/overruled). */
|
||||
corroboration_count?: number;
|
||||
corroboration_negative?: boolean;
|
||||
/* #84.2 near-duplicate clustering (present only when fetched with cluster=true):
|
||||
* same-precedent halachot within the cluster cosine share a cluster_id, so the
|
||||
* UI collapses them into one review card. cluster_size === 1 → singleton. */
|
||||
cluster_id?: string;
|
||||
cluster_size?: number;
|
||||
};
|
||||
|
||||
export type RelatedCase = {
|
||||
@@ -566,14 +571,32 @@ export function useRequestHalachotExtraction() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useHalachotPending(limit = 200) {
|
||||
/** #84.1/#84.2/#84.3 — the chair review queue.
|
||||
*
|
||||
* Default ("clean") view: quality-gated (flagged items hidden), priority-ordered
|
||||
* (most-uncertain/negatively-treated first), and near-duplicate-clustered into
|
||||
* one card. Pass `needsFix: true` for the 'needs extraction fix' bucket — every
|
||||
* pending item carrying a quality flag (filtered client-side). */
|
||||
export function useHalachotPending(
|
||||
opts: { limit?: number; needsFix?: boolean } = {},
|
||||
) {
|
||||
const { limit = 200, needsFix = false } = opts;
|
||||
const qs = needsFix
|
||||
? `review_status=pending_review&exclude_low_quality=false&limit=${limit}`
|
||||
: `review_status=pending_review&exclude_low_quality=true`
|
||||
+ `&order_by_priority=true&cluster=true&limit=${limit}`;
|
||||
return useQuery({
|
||||
queryKey: libraryKeys.halachotPending(),
|
||||
queryFn: ({ signal }) =>
|
||||
apiRequest<{ items: Halacha[]; count: number }>(
|
||||
`/api/halachot?review_status=pending_review&limit=${limit}`,
|
||||
queryKey: [...libraryKeys.halachotPending(), needsFix ? "needsfix" : "clean"],
|
||||
queryFn: async ({ signal }) => {
|
||||
const res = await apiRequest<{ items: Halacha[]; count: number }>(
|
||||
`/api/halachot?${qs}`,
|
||||
{ signal },
|
||||
),
|
||||
);
|
||||
if (!needsFix) return res;
|
||||
// needs-fix bucket = pending items that carry a quality flag
|
||||
const items = res.items.filter((h) => (h.quality_flags?.length ?? 0) > 0);
|
||||
return { items, count: items.length };
|
||||
},
|
||||
staleTime: 5_000,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user