Merge pull request 'fix(ui): כלי הלשונית דרך fetch של ה-worker; דשבורד דרך status-index (legal-ai #1117)' (#21) from fix/1117-ui-handlers into main
All checks were successful
INV-INT9 issue.status write-ownership / int9-guard (push) Successful in 5s
All checks were successful
INV-INT9 issue.status write-ownership / int9-guard (push) Successful in 5s
This commit was merged in pull request #21.
This commit is contained in:
@@ -194,6 +194,7 @@ export class LegalApi {
|
||||
export interface CaseStatusEntry {
|
||||
case_number: string;
|
||||
status: string;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface CaseSummary {
|
||||
|
||||
@@ -1391,7 +1391,7 @@ const plugin = definePlugin({
|
||||
if (!caseNumber) return null;
|
||||
const apiBase = await resolveApiBase(ctx, companyIdOf(params));
|
||||
try {
|
||||
const resp = await ctx.http.fetch(
|
||||
const resp = await fetchLegalApi(
|
||||
`${apiBase}/api/cases/${encodeURIComponent(caseNumber)}/legal-arguments`,
|
||||
);
|
||||
if (!resp.ok) {
|
||||
@@ -1428,7 +1428,7 @@ const plugin = definePlugin({
|
||||
if (!caseNumber) return [];
|
||||
const apiBase = await resolveApiBase(ctx, companyIdOf(params));
|
||||
try {
|
||||
const resp = await ctx.http.fetch(
|
||||
const resp = await fetchLegalApi(
|
||||
`${apiBase}/api/cases/${encodeURIComponent(caseNumber)}/precedents`,
|
||||
);
|
||||
if (!resp.ok) {
|
||||
@@ -1467,7 +1467,7 @@ const plugin = definePlugin({
|
||||
const url = new URL(`${apiBase}/api/missing-precedents`);
|
||||
url.searchParams.set("case_number", caseNumber);
|
||||
url.searchParams.set("status", "open");
|
||||
const resp = await ctx.http.fetch(url.toString());
|
||||
const resp = await fetchLegalApi(url.toString());
|
||||
if (!resp.ok) {
|
||||
ctx.logger.warn("legal-case-missing-precedents: API error", {
|
||||
caseNumber,
|
||||
@@ -1488,13 +1488,13 @@ const plugin = definePlugin({
|
||||
|
||||
ctx.data.register("legal-dashboard-stats", async () => {
|
||||
try {
|
||||
const cases = await api.listCases();
|
||||
const cases = await api.listCaseStatuses();
|
||||
const byStatus: Record<string, number> = {};
|
||||
let weekActivity = 0;
|
||||
const weekAgoMs = Date.now() - 7 * 24 * 60 * 60 * 1000;
|
||||
for (const c of cases) {
|
||||
byStatus[c.status] = (byStatus[c.status] ?? 0) + 1;
|
||||
const updated = (c as { updated_at?: string | null }).updated_at;
|
||||
const updated = c.updated_at;
|
||||
if (updated) {
|
||||
const t = Date.parse(updated);
|
||||
if (!Number.isNaN(t) && t >= weekAgoMs) weekActivity += 1;
|
||||
|
||||
Reference in New Issue
Block a user