mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 03:50:30 +00:00
feat(atlas): show the most recently visited countries first on the dashboard (#2648)
The place and endpoint reads behind the passport tile now carry the last day of each started trip, and getTravelStats orders the countries by their latest visit, with countries only marked by hand after them. The country set is unchanged; repository, parity and service tests pin the order.
This commit is contained in:
@@ -166,11 +166,26 @@ describe('PlaceRegionsRepository.listStartedTripPlaceCountriesForUser (AT44)', (
|
||||
|
||||
const today = '2026-01-01';
|
||||
const expected = [
|
||||
{ id: cached.id, lat: 48.85, lng: 2.35, address: null, country_code: 'FR' },
|
||||
{ id: uncached.id, lat: 41.9022, lng: 12.4539, address: null, country_code: null },
|
||||
{ id: cached.id, lat: 48.85, lng: 2.35, address: null, country_code: 'FR', trip_last_date: '2020-01-10' },
|
||||
{ id: uncached.id, lat: 41.9022, lng: 12.4539, address: null, country_code: null, trip_last_date: '2020-01-10' },
|
||||
];
|
||||
expect(await repo.listStartedTripPlaceCountriesForUser(owner.id, today)).toEqual(expected);
|
||||
expect(await repo.listStartedTripPlaceCountriesForUser(member.id, today)).toEqual(expected);
|
||||
expect(await repo.listStartedTripPlaceCountriesForUser(stranger.id, today)).toEqual([]);
|
||||
});
|
||||
|
||||
it('PLACEREGREPO-010: dates each place by its own trip, the start standing in for a missing end (#2648)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const ended = createTrip(testDb, user.id, { start_date: '2020-01-01', end_date: '2020-01-10' });
|
||||
const openEnded = createTrip(testDb, user.id, { start_date: '2021-07-01' });
|
||||
const first = createPlace(testDb, ended.id);
|
||||
const second = createPlace(testDb, openEnded.id);
|
||||
|
||||
const rows = await repo.listStartedTripPlaceCountriesForUser(user.id, '2026-01-01');
|
||||
|
||||
expect(rows.map((row) => [row.id, row.trip_last_date])).toEqual([
|
||||
[first.id, '2020-01-10'],
|
||||
[second.id, '2021-07-01'],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,13 +41,15 @@ const AT6 = (n: number) => `
|
||||
WHERE r.trip_id IN (${Array(n).fill('?').join(',')}) AND e.role IN ('from', 'to')
|
||||
AND ${TRAVELER_OWNS}`;
|
||||
|
||||
// AT45 also names the trip's last day since #2648, the dashboard's order of countries.
|
||||
const AT45 = `
|
||||
SELECT DISTINCT e.id, e.reservation_id, r.trip_id, e.role, e.code, e.lat, e.lng, e.local_date, e.local_time,
|
||||
r.type AS reservation_type, r.status AS reservation_status,
|
||||
CASE e.role
|
||||
WHEN 'to' THEN COALESCE(r.reservation_end_time, r.reservation_time)
|
||||
ELSE COALESCE(r.reservation_time, r.reservation_end_time)
|
||||
END AS fallback_time
|
||||
END AS fallback_time,
|
||||
COALESCE(t.end_date, t.start_date) AS trip_last_date
|
||||
FROM reservation_endpoints e
|
||||
JOIN reservations r ON e.reservation_id = r.id
|
||||
JOIN trips t ON r.trip_id = t.id
|
||||
|
||||
Reference in New Issue
Block a user