Skip to content

Commit 63c6354

Browse files
jdamcdclaude
andcommitted
Reduce false positives in travel event detection
- Remove "tour" from travel keywords (concert tours are not travel) - Only detect flight numbers in event summary, not description/location (fixes false positives from UK postcodes and confirmation codes) - Update empty state text and centre it Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2ecf4c5 commit 63c6354

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/components/VisitList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ export function VisitList({
113113

114114
<div className="flex-1 overflow-y-auto">
115115
{sortedVisits.length === 0 ? (
116-
<div className="p-4 text-center text-gray-500 dark:text-gray-400">
117-
No countries visited yet
116+
<div className="flex items-center justify-center h-full p-4 text-gray-500 dark:text-gray-400">
117+
Import a calendar to get started
118118
</div>
119119
) : (
120120
<ul className="divide-y divide-gray-100 dark:divide-gray-700">

src/lib/country-extractor.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ describe('extractCountryVisits', () => {
201201
expect(visits[0].countryCode).toBe('US');
202202
});
203203

204+
it('only detects flight numbers in summary, not description or location', () => {
205+
const events: CalendarEvent[] = [
206+
createEvent({
207+
summary: 'Local event',
208+
description: 'Reference: AB123',
209+
location: '123 Main St, London SW1A 1AA',
210+
startDate: new Date('2024-01-15'),
211+
endDate: new Date('2024-01-15'),
212+
}),
213+
];
214+
const visits = extractCountryVisits(events);
215+
expect(visits).toHaveLength(0);
216+
});
217+
204218
it('detects train stations as travel indicator', () => {
205219
const events: CalendarEvent[] = [
206220
createEvent({

src/lib/country-extractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const HOTEL_KEYWORDS = [
2626
];
2727

2828
const TRAVEL_KEYWORDS = [
29-
'trip', 'travel', 'vacation', 'holiday', 'visit', 'tour',
29+
'trip', 'travel', 'vacation', 'holiday', 'visit',
3030
'excursion', 'journey', 'abroad'
3131
];
3232

@@ -173,7 +173,7 @@ function isTravelEvent(event: CalendarEvent): boolean {
173173
const hasHotelKeyword = HOTEL_KEYWORDS.some((kw) => matchesWholeWord(searchText, kw));
174174
const hasTravelKeyword = TRAVEL_KEYWORDS.some((kw) => matchesWholeWord(searchText, kw));
175175
const hasAirportCode = extractAirportCodes(fullText).length > 0;
176-
const hasFlightNum = hasFlightNumber(fullText);
176+
const hasFlightNum = hasFlightNumber(event.summary);
177177

178178
if (hasFlightKeyword || hasHotelKeyword || hasTravelKeyword || hasAirportCode || hasFlightNum) {
179179
return true;

0 commit comments

Comments
 (0)