Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 32x 32x 32x 32x 3x 32x | import { KpiStrip, SparkBars, type StatTileProps } from "@/components/charts";
import type { Knowledge, KnowledgeStats, RepositoryStats } from "@/objects/Knowledge";
import React from "react";
import { TypeMix } from "../cardParts";
import { citationTitles, formatAgo, indexedShare } from "../figures";
import SourceMap from "../map/SourceMap";
import RecommendationsCard from "../recommendations/RecommendationsCard";
import RepositoryTrustCard from "./RepositoryTrustCard";
/**
* A repository at a glance: its figures (its sources' added up), the map
* of how its sources connect, and what is on record about relying on each.
*/
function tilesFor(stats: RepositoryStats | null, loading: boolean): StatTileProps[] {
const indexed = stats?.documents_indexed ?? 0;
const total = stats?.documents_total ?? 0;
const share = indexedShare(indexed, total);
return [
{
label: "Sources",
value: (stats?.sources ?? 0).toLocaleString(),
hint: stats && stats.sources > 0 ? <TypeMix byType={stats.by_type} /> : "None yet",
loading,
},
{
label: "Held",
value: (stats?.items ?? 0).toLocaleString(),
hint: "Documents, pages and entities",
loading,
},
{
label: "Indexed",
value: share === null ? "—" : `${Math.round(share * 100)}%`,
hint: total ? `${indexed.toLocaleString()} of ${total.toLocaleString()}` : "Nothing to index",
loading,
},
{
label: "Needs attention",
value: (stats?.attention_sources ?? 0).toLocaleString(),
hint: stats?.last_updated_at ? `Updated ${formatAgo(stats.last_updated_at)}` : "Of its sources",
loading,
},
{
label: "Agents",
value: (stats?.agents ?? 0).toLocaleString(),
hint: "That can retrieve from it here",
loading,
},
{
label: "Retrieved · 30 days",
value: (stats?.retrieved ?? 0).toLocaleString(),
hint: "Answers its sources' passages were given to",
loading,
},
{
label: "Cited · 30 days",
value: (stats?.citations ?? 0).toLocaleString(),
hint:
stats && stats.citations_daily.length ? (
<SparkBars
values={stats.citations_daily}
titles={citationTitles(stats.citations_daily)}
label="Answers citing its sources, per day over 30 days"
height={16}
/>
) : undefined,
loading,
},
];
}
export interface RepositoryOverviewProps {
repositoryId: string;
stats: RepositoryStats | null;
figures: Map<string, KnowledgeStats>;
members: Knowledge[];
loading: boolean;
/** Adds a suggested source; absent when the viewer may not change it. */
onAdd?: (knowledgeId: string) => void;
adding?: boolean;
}
const RepositoryOverview: React.FC<RepositoryOverviewProps> = ({
repositoryId,
stats,
figures,
members,
loading,
onAdd,
adding,
}) => (
<div className="space-y-5">
<KpiStrip tiles={tilesFor(stats, loading)} />
<RecommendationsCard
repositoryId={repositoryId}
title="What to improve"
description="From what its agents were asked, what reached their answers, and how its sources are kept."
/>
<SourceMap repositoryId={repositoryId} figures={figures} onAdd={onAdd} adding={adding} />
<RepositoryTrustCard repositoryId={repositoryId} members={members} />
</div>
);
export default RepositoryOverview;
|