All files / apps/developer-portal/app/composables useWorkQueue.ts

81.25% Statements 13/16
75% Branches 3/4
62.5% Functions 5/8
80% Lines 12/15

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                    32x 10x 10x 10x 10x 10x 10x   10x                                                   3x                   2x             1x                   10x    
import { openAudits } from "#layers/audits/shared/auditReports.ts";
import { toImplement } from "#layers/decisions/shared/decisionReports.ts";
import { toCollectionPath } from "#layers/docs/shared/docPages.ts";
import { sortIssues } from "#layers/github/app/utils/issues.ts";
import { brokenPages } from "#layers/snapshot/app/utils/docs.ts";
import { unreleased } from "#layers/snapshot/app/utils/metrics.ts";
import type { QueueKind } from "~/types/QueueKind";
import type { QueueRow } from "~/types/QueueRow";
 
/** Everything open across the repo for Home's queue, one list per kind of work. */
export const useWorkQueue = () => {
    const { t } = useI18n();
    const { shown: issues } = useIssues();
    const decisions = useDecisionReports();
    const audits = useAuditReports();
    const metrics = metricsArtifact();
    const docs = docsArtifact();
 
    const rows = computed((): Record<QueueKind, QueueRow[]> => ({
        issues: sortIssues(issues.value.issues).map((issue) => ({
            key: `issue-${issue.number}`,
            id: `#${issue.number}`,
            title: issue.title,
            meta: shortAge(issue.updatedAt, t),
            to: issue.url,
            external: true,
        })),
        decisions: toImplement(decisions.value).map((report) => ({
            key: `decision-${report.id}`,
            id: report.number,
            title: report.title,
            meta: t("workQueue.rows.toImplement"),
            to: `/decisions/${report.id}`,
        })),
        audits: openAudits(audits.value).map((report) => ({
            key: `audit-${report.id}`,
            id: report.date.slice("YYYY-".length),
            title: report.title,
            meta: t("workQueue.rows.auditOpen", {
                open: report.counts.open,
                total: report.findings.length,
            }),
            to: `/audits/${report.id}`,
        })),
        releases: unreleased(metrics?.projects).map((project) => ({
            key: `release-${project.root}`,
            id: `+${project.unreleasedCommits}`,
            title: project.name,
            meta: t("workQueue.rows.release", {
                version: project.currentVersion ?? t("workQueue.rows.unversioned"),
            }),
            to: `/projects/${folderOf(project.root)}`,
        })),
        attention: [
            ...(metrics?.invariantFindings ?? []).map((finding) => ({
                key: `finding-${finding.id}`,
                id: t("workQueue.rows.invariant"),
                title: finding.title,
                meta: finding.detail,
                to: null,
            })),
            ...brokenPages(docs).map((page) => ({
                key: `docs-${page.path}`,
                id: t("workQueue.rows.link"),
                title: page.path,
                meta: t("workQueue.rows.brokenLinks", { count: page.brokenLinks.length }),
                to: `/wiki${toCollectionPath(page.path)}`,
            })),
        ],
    }));
 
    return { rows, issues };
};