mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 11:24:00 +00:00
fix(transit): count distinct coverage regions
This commit is contained in:
1 parent
53d30c9e80
commit
c68f167acb
2 files changed
+34
-1
No files matched your search
@@ -12,6 +12,11 @@ import {
|
|||||||
} from '../../data/transitFeeds.js';
|
} from '../../data/transitFeeds.js';
|
||||||
import { transitModeTier } from '../../data/transitPresetStyle.js';
|
import { transitModeTier } from '../../data/transitPresetStyle.js';
|
||||||
|
|
||||||
|
/** Regions, not feeds: one region can carry several feeds (Rio has two). */
|
||||||
|
const TRANSIT_REGION_COUNT = new Set(
|
||||||
|
TRANSIT_ENABLED_FEEDS.map((feed) => feed.region),
|
||||||
|
).size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The registry entry behind a vehicle. Live feeds answer first so a feed the
|
* The registry entry behind a vehicle. Live feeds answer first so a feed the
|
||||||
* session disabled stops supplying vocabulary; the registry is the fallback,
|
* session disabled stops supplying vocabulary; the registry is the fallback,
|
||||||
@@ -249,7 +254,7 @@ export function createQueries({ state, parts }) {
|
|||||||
// English data (the analyst's empty note to the model); the voice
|
// English data (the analyst's empty note to the model); the voice
|
||||||
// card shows it through NOTE_PATTERNS (voice/resultDisplay.js).
|
// card shows it through NOTE_PATTERNS (voice/resultDisplay.js).
|
||||||
coverage: state._altitudeGateOpen
|
coverage: state._altitudeGateOpen
|
||||||
? `No feed here yet · ${TRANSIT_ENABLED_FEEDS.length} regions available`
|
? `No feed here yet · ${TRANSIT_REGION_COUNT} regions available`
|
||||||
: `Fly below ${Math.round(ACTIVATION_ALTITUDE_M / 1000).toLocaleString('en-US')} km to a covered region`,
|
: `Fly below ${Math.round(ACTIVATION_ALTITUDE_M / 1000).toLocaleString('en-US')} km to a covered region`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { createQueries } from './queries.js';
|
||||||
|
import { TRANSIT_ENABLED_FEEDS } from '../../data/transitFeeds.js';
|
||||||
|
|
||||||
|
test('the empty-coverage note counts regions, not feeds', () => {
|
||||||
|
const rio = TRANSIT_ENABLED_FEEDS.filter(
|
||||||
|
(feed) => feed.region === 'Rio de Janeiro, RJ',
|
||||||
|
);
|
||||||
|
assert.equal(rio.length, 2, 'Rio is one region with two feeds');
|
||||||
|
const regions = new Set(TRANSIT_ENABLED_FEEDS.map((feed) => feed.region));
|
||||||
|
assert.ok(regions.size < TRANSIT_ENABLED_FEEDS.length);
|
||||||
|
|
||||||
|
const stats = createQueries({
|
||||||
|
state: {
|
||||||
|
_activeFeeds: new Map(),
|
||||||
|
_vehicles: new Map(),
|
||||||
|
_enabled: true,
|
||||||
|
_altitudeGateOpen: true,
|
||||||
|
},
|
||||||
|
parts: {},
|
||||||
|
}).methods.getStats();
|
||||||
|
assert.equal(stats.status, 'zoom-in');
|
||||||
|
assert.equal(
|
||||||
|
stats.coverage,
|
||||||
|
`No feed here yet · ${regions.size} regions available`,
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user