mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
fix(usage): derive window names and unify pin selection (#5903)
* fix(usage): derive window names and unify pin selection Quota slots do not identify a period. Derive numeric windows and IDs from reported duration and quota scope; keep unknown lengths neutral. Resolve source defaults and explicit pins through one model, with a persisted empty selection distinct from defaults. * fix(plugins): declare the duration helper host requirement * fix(usage): verify persisted selections at the storage boundary
This commit is contained in:
+8
-1
@@ -1,5 +1,6 @@
|
||||
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
||||
import { z } from "zod";
|
||||
import { windowFromReportedDuration } from "@getpaseo/plugin/server/usage";
|
||||
|
||||
let fetches = 0;
|
||||
export default function contribute(server: PluginServerContext) {
|
||||
@@ -32,7 +33,13 @@ export default function contribute(server: PluginServerContext) {
|
||||
fetches++;
|
||||
return {
|
||||
status: "available",
|
||||
windows: [{ id: "count", label: "Count", usedPct: fetches }],
|
||||
windows: [
|
||||
windowFromReportedDuration({
|
||||
durationSeconds: 604800,
|
||||
unknown: { id: "unknown", label: "Limit", shortLabel: "" },
|
||||
utilizationPct: fetches,
|
||||
}),
|
||||
],
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
||||
import { z } from "zod";
|
||||
import { windowFromReportedDuration } from "@getpaseo/plugin/server/usage";
|
||||
|
||||
let fetches = 0;
|
||||
export default function contribute(server: PluginServerContext) {
|
||||
@@ -32,7 +33,13 @@ export default function contribute(server: PluginServerContext) {
|
||||
fetches++;
|
||||
return {
|
||||
status: "available",
|
||||
windows: [{ id: "count", label: "Count", usedPct: fetches }],
|
||||
windows: [
|
||||
windowFromReportedDuration({
|
||||
durationSeconds: 604800,
|
||||
unknown: { id: "unknown", label: "Limit", shortLabel: "" },
|
||||
utilizationPct: fetches,
|
||||
}),
|
||||
],
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -57,6 +57,13 @@ test("lists built-in and subprocess usage; validates input and isolates fetch er
|
||||
await client.installDirectoryPlugin(subprocessDirectory, "fixture-directory");
|
||||
const both = await client.listUsageReports({ forceRefresh: true });
|
||||
expect(both.reports).toHaveLength(8);
|
||||
for (const id of ["fixture:one", "fixture-directory:one"]) {
|
||||
expect(both.reports.find((entry) => entry.id === id)?.report.windows[0]).toMatchObject({
|
||||
id: "weekly",
|
||||
label: "Weekly",
|
||||
shortLabel: "wk",
|
||||
});
|
||||
}
|
||||
await client.patchDaemonConfig({ pluginsEnabled: false });
|
||||
await expect.poll(async () => (await client.listUsageReports()).reports.length).toBe(4);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user