Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion stats/src/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ ${privateView ? opsSection : ''} <section id="private-grid" class="two-col" h
setText('fleet-total', number(view.reports_30d) + ' / 30d');
note.textContent = privateMode
? 'Private aggregate view. Reports are daily check-ins, not users or unique boxes.'
: 'Public totals use a minimum group size of ' + view.minimum + '. A version or integration appears only when its own count reaches the same limit.';
: view.minimum === 1
? 'Every daily report counts. A report is not a user or a unique box.'
: 'Public totals use a minimum group size of ' + view.minimum + '. A version or integration appears only when its own count reaches the same limit.';
}
if (!privateMode && view.state === 'withheld') {
const chart = $('fleet-chart');
Expand Down
2 changes: 1 addition & 1 deletion stats/src/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AppEnv } from './types.ts'

// FTW Cloud's own group size for a public day. 5 since 23 October 2026;
// 10 before, kept while an older Cloud may still answer.
const PUBLIC_FLEET_MINIMUMS = [5, 10]
const PUBLIC_FLEET_MINIMUMS = [1, 5, 10]
const dimensions = ['ftw_versions', 'channels', 'drivers', 'battery_kwh', 'price_zones', 'install_age'] as const
export interface PublicFleetDay { date: string; reports: number | null }
export interface PublicFleetFeed { schema: 'ftw.fleet-public/1'; minimum: number; meaning: string; observed_at: string; days: PublicFleetDay[] }
Expand Down
2 changes: 1 addition & 1 deletion stats/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ function byteCountBand(value: number): string {

function publicMinimum(value: string): number {
const parsed = Number(value)
return Number.isSafeInteger(parsed) && parsed >= 5 && parsed <= 1000 ? parsed : 10
return Number.isSafeInteger(parsed) && parsed >= 1 && parsed <= 1000 ? parsed : 10
}

function latestTimestamp(values: Array<string | null>): string | null {
Expand Down
12 changes: 12 additions & 0 deletions stats/test/worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()=>{
Expand Down Expand Up @@ -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')
})

2 changes: 2 additions & 0 deletions stats/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
4 changes: 2 additions & 2 deletions stats/worker-configuration.d.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion stats/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading