mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 02:14:01 +00:00
Merge pull request #1353 from rudycelekli/fix/transit-ninety-second-age
Correct the transit report-age label and document its rounding rule.
This commit is contained in:
4 files changed
+29
-2
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
- Count a transit report that is 90 seconds old as one minute. The card kept
|
||||||
|
seconds through 89s, then rounded 90s up to "Reported 2 min ago"
|
||||||
|
(Rudy Celekli, @rudycelekli, #1353).
|
||||||
@@ -4197,7 +4197,9 @@ to 0.45 at two minutes, 0.20 at ten minutes and 0.08 at fifteen minutes.
|
|||||||
|
|
||||||
**Cards and DETECT.** The card presents route, mode/operator, displayed motion,
|
**Cards and DETECT.** The card presents route, mode/operator, displayed motion,
|
||||||
display delay and newest-report age, reported speed/stop, vehicle ID, and
|
display delay and newest-report age, reported speed/stop, vehicle ID, and
|
||||||
available trail duration. Its anchor follows the rendered marker; text is
|
available trail duration. Report age is rounded to whole seconds and stays in seconds while that rounded
|
||||||
|
count is below 90; otherwise it shows completed minutes calculated from the
|
||||||
|
rounded second count. Its anchor follows the rendered marker; text is
|
||||||
checked at 4 Hz and published when it changes. DETECT labels retain route,
|
checked at 4 Hz and published when it changes. DETECT labels retain route,
|
||||||
mode and motion, with the selected label suppressed beside its fuller card.
|
mode and motion, with the selected label suppressed beside its fuller card.
|
||||||
Candidate membership changes on revisions, coalesced at 4 Hz; paints read
|
Candidate membership changes on revisions, coalesced at 4 Hz; paints read
|
||||||
|
|||||||
@@ -442,10 +442,12 @@ export function buildTransitSelectionCopy(
|
|||||||
? entry.sample.latestReportAgeMs
|
? entry.sample.latestReportAgeMs
|
||||||
: vehicleFixAgeMs(record, nowMs, fetchedAtMs)) / 1000,
|
: vehicleFixAgeMs(record, nowMs, fetchedAtMs)) / 1000,
|
||||||
);
|
);
|
||||||
|
// Seconds through 89s, then whole minutes. Rounding 90s up would skip
|
||||||
|
// "1 min" and call a minute-and-a-half-old report two minutes old.
|
||||||
const reported =
|
const reported =
|
||||||
ageS < 90
|
ageS < 90
|
||||||
? t('Reported {seconds} s ago', { seconds: ageS })
|
? t('Reported {seconds} s ago', { seconds: ageS })
|
||||||
: t('Reported {minutes} min ago', { minutes: Math.round(ageS / 60) });
|
: t('Reported {minutes} min ago', { minutes: Math.floor(ageS / 60) });
|
||||||
// A time the feed did not give for THIS vehicle is labelled, so the card
|
// A time the feed did not give for THIS vehicle is labelled, so the card
|
||||||
// never presents a borrowed or inferred time as the vehicle's own report.
|
// never presents a borrowed or inferred time as the vehicle's own report.
|
||||||
const ownTime =
|
const ownTime =
|
||||||
|
|||||||
@@ -39,6 +39,26 @@ test('en: the copy is unchanged with and without the i18n t()', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a report 90 seconds old reads as 1 minute, not 2', () => {
|
||||||
|
setLocale('en');
|
||||||
|
const line = (ageMs) =>
|
||||||
|
buildTransitSelectionCopy(
|
||||||
|
feed,
|
||||||
|
{
|
||||||
|
id: 'age',
|
||||||
|
lat: 1,
|
||||||
|
lon: 1,
|
||||||
|
timestamp: Math.floor((now - ageMs) / 1000),
|
||||||
|
timestampSource: 'vehicle',
|
||||||
|
},
|
||||||
|
'bus',
|
||||||
|
now,
|
||||||
|
).details[1];
|
||||||
|
assert.equal(line(89_000), 'Reported 89 s ago');
|
||||||
|
assert.equal(line(90_000), 'Reported 1 min ago');
|
||||||
|
assert.equal(line(120_000), 'Reported 2 min ago');
|
||||||
|
});
|
||||||
|
|
||||||
for (const locale of ['es', 'ru']) {
|
for (const locale of ['es', 'ru']) {
|
||||||
test(`${locale}: the Transit card is in the UI language`, () => {
|
test(`${locale}: the Transit card is in the UI language`, () => {
|
||||||
setLocale(locale);
|
setLocale(locale);
|
||||||
|
|||||||
Reference in new issue
Block a user