diff --git a/stats/README.md b/stats/README.md index ea14155..8397a3d 100644 --- a/stats/README.md +++ b/stats/README.md @@ -23,7 +23,7 @@ show smaller aggregate counts, but it requires a valid Cloudflare Access JWT. The separate relay is retired. Earlier reports remain as an archive and do not measure current Cloud use. Core's anonymous daily reports now go to -Cloud; the Worker reads its thresholded public view at `/v1/fleet/public`. They still cannot count unique installations. +Cloud; the Worker reads its public view at `/v1/fleet/public`, where every report counts. They still cannot count unique installations. The installation estimate divides reports from the last seven complete UTC days by seven, then rounds to a whole installation. Core normally reports diff --git a/stats/src/dashboard.ts b/stats/src/dashboard.ts index 1d6c99a..7de808f 100644 --- a/stats/src/dashboard.ts +++ b/stats/src/dashboard.ts @@ -458,7 +458,9 @@ ${privateView ? opsSection : ''}
= 5 && parsed <= 1000 ? parsed : 10 + return Number.isSafeInteger(parsed) && parsed >= 1 && parsed <= 1000 ? parsed : 10 } function latestTimestamp(values: Array): string | null { diff --git a/stats/test/worker.test.ts b/stats/test/worker.test.ts index 4517812..a766728 100644 --- a/stats/test/worker.test.ts +++ b/stats/test/worker.test.ts @@ -790,6 +790,7 @@ describe('installation estimates',()=>{ expect(()=>parseFleet(v,now)).toThrow('small fleet label') v.days[0]!.drivers={};v.days[0]!.reports=4 expect(()=>parseFleet(v,now)).toThrow('small fleet count') + expect(parseFleet({...fleetView(now),minimum:1},now).minimum).toBe(1) expect(()=>parseFleet({...fleetView(now),minimum:3},now)).toThrow('invalid public fleet') }) it('collects the safe Cloud feed independently of hourly energy approval',async()=>{ @@ -909,3 +910,14 @@ describe('Cloud collector redirects in the Workers runtime', () => { } ) }) + +it('counts every report when the minimum is one', () => { + const now = Date.UTC(2026, 10, 8, 12) + const date = new Date(now - 86_400_000).toISOString().slice(0, 10) + const empty = { ftw_versions: {}, channels: {}, drivers: { 'sma_pv@1.1.1': 1 }, battery_kwh: { '12': 1 }, price_zones: { SE3: 1 }, install_age: {} } + const view = publicFleet([{ date, reports: 1, ...empty } as never], 1, now) as { state: string; reports_30d: number; dimensions: { drivers: unknown } } + expect(view.state).not.toBe('withheld') + expect(view.reports_30d).toBe(1) + expect(JSON.stringify(view.dimensions.drivers)).toContain('sma_pv@1.1.1') +}) + diff --git a/stats/vitest.config.ts b/stats/vitest.config.ts index 1140131..f9a2b72 100644 --- a/stats/vitest.config.ts +++ b/stats/vitest.config.ts @@ -19,6 +19,8 @@ export default defineConfig({ RELAY_INGEST_SECRET: '0123456789abcdef0123456789abcdef', ACCESS_TEAM_DOMAIN: 'https://test.cloudflareaccess.com', ACCESS_AUD: 'test-audience', + // The floor's own logic stays under test; production's is 1. + PUBLIC_MIN_REPORTS: '5', TEST_MIGRATIONS: migrations, }, }, diff --git a/stats/worker-configuration.d.ts b/stats/worker-configuration.d.ts index 1b4f4fc..3f94119 100644 --- a/stats/worker-configuration.d.ts +++ b/stats/worker-configuration.d.ts @@ -1,11 +1,11 @@ /* eslint-disable */ -// Generated by Wrangler by running `wrangler types --config=stats/wrangler.jsonc --include-runtime=false stats/worker-configuration.d.ts` (hash: 0eef6eb84779d2e6523fd38951946019) +// Generated by Wrangler by running `wrangler types --config=stats/wrangler.jsonc --include-runtime=false stats/worker-configuration.d.ts` (hash: ef266519cf5899c99227b544b275c8f8) interface __BaseEnv_Env { DB: D1Database; GITHUB_OWNER: "srcfl"; GITHUB_REPOS: "ftw,device-drivers,ftw-cloud,ftw-app,ftw-webapp,ftw-web"; SITE_HOSTNAME: "app.ftw.energy"; - PUBLIC_MIN_REPORTS: "5"; + PUBLIC_MIN_REPORTS: "1"; CLOUDFLARE_ZONE_ID: "b8e2cf4b19abbeb535cca652750916c9"; ACCESS_TEAM_DOMAIN: "https://sourceful.cloudflareaccess.com"; ACCESS_AUD: "980a936eae5215f4484780b68996a4985f435a0e19cd8d11c13225b3f74844cd"; diff --git a/stats/wrangler.jsonc b/stats/wrangler.jsonc index 490d93e..996ee32 100644 --- a/stats/wrangler.jsonc +++ b/stats/wrangler.jsonc @@ -15,7 +15,7 @@ "GITHUB_OWNER": "srcfl", "GITHUB_REPOS": "ftw,device-drivers,ftw-cloud,ftw-app,ftw-webapp,ftw-web", "SITE_HOSTNAME": "app.ftw.energy", - "PUBLIC_MIN_REPORTS": "5", + "PUBLIC_MIN_REPORTS": "1", "CLOUDFLARE_ZONE_ID": "b8e2cf4b19abbeb535cca652750916c9", "ACCESS_TEAM_DOMAIN": "https://sourceful.cloudflareaccess.com", "ACCESS_AUD": "980a936eae5215f4484780b68996a4985f435a0e19cd8d11c13225b3f74844cd"