Skip to content

Commit

Permalink
Fix Bircom messages
Browse files Browse the repository at this point in the history
Correctly look for the last known position
  • Loading branch information
vicb committed Sep 5, 2024
1 parent d575a2f commit 63274ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions apps/fetcher/src/app/trackers/meshbir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ describe('parse', () => {
});

it('associates message with the last known position when recent', () => {
jest.useFakeTimers({ now: 123500 });
jest.useFakeTimers({ now: 234500 });
expect(
parse(
[
{
time: 123440,
time: 234440,
type: 'message',
user_id: '12345678-1234-1234-1234-123456789012',
message: 'message',
Expand All @@ -302,10 +302,10 @@ describe('parse', () => {
{
'10': protos.Pilot.create({
track: protos.LiveTrack.create({
alt: [1],
lat: [2],
lon: [3],
timeSec: [123],
alt: [10, 11],
lat: [20, 21],
lon: [30, 31],
timeSec: [123, 234],
}),
}),
},
Expand All @@ -315,12 +315,12 @@ describe('parse', () => {
Map {
"12345678-1234-1234-1234-123456789012" => [
{
"alt": 1,
"lat": 2,
"lon": 3,
"alt": 11,
"lat": 21,
"lon": 31,
"message": "message",
"name": "meshbir",
"timeMs": 123500,
"timeMs": 234500,
},
],
}
Expand Down
2 changes: 1 addition & 1 deletion apps/fetcher/src/app/trackers/meshbir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function parse(
continue;
}
const nowMs = Date.now();
const lastFixAgeSec = Math.round(nowMs / 1000) - track.timeSec[0];
const lastFixAgeSec = Math.round(nowMs / 1000) - track.timeSec.at(-1);
if (lastFixAgeSec > messageAffinityMin * 60) {
continue;
}
Expand Down

0 comments on commit 63274ad

Please sign in to comment.