Fair Isn't the Average: Fixing Meetup Suggestions in the Middle of Nowhere
Meet Me in the Middle is a small app I built: everyone adds where they're starting from, and it suggests places to meet where nobody gets stuck with the long trip. But with two people, the top suggestion was often somewhere in the middle of nowhere.
The worst case I found was a pair in Hebbal and Kengeri, in Bengaluru. The app's top pick for "restaurants and cafes" was a precast cement yard with 37 reviews. Second place was a pharmacy. Both were roughly in the middle, and nobody would ever meet at either.
How the search worked
participants
-> a central point (geometric median, nudged towards whoever is farthest)
-> nearby places of the requested types, in a circle around that point
-> the 10 highest-rated places
-> travel times from everyone to each place (one Distance Matrix call)
-> ranked by average travel timeWith two people the central point is simply the midpoint between them, and that point was fine. The problems were in the steps after it.
Two problems hiding in plain sight
The ranking ignored fairness
Places were sorted by average drive time. With two people, a 5 + 35 minute split has the same average as 20 + 20. The whole pitch of the app is that nobody gets the long trip, and the ranking couldn't tell those two apart.
The shortlist trusted star ratings
Each search makes a single Distance Matrix call, so only 10 candidates get real travel times. Those 10 were picked by star rating alone, which means a 5.0★ place with 1 review beat a 4.3★ place with 8,000. When the midpoint lands on a highway, a lake or an empty stretch of road, the search circle only holds obscure roadside spots, and the ones with a handful of perfect reviews win.
The fix
All three changes live in one file, meetingSearch.ts.
1. Rank by the worst trip
The new cost leads with the longest trip anyone makes, adds half the average, and gives popular places a small head start:
const cost = (place: PlaceWithTravel): number => {
if (place.avgDuration === null || place.travelTimes.length < origins.length) {
return Infinity; // missing a route for someone: rank last
}
const longest = Math.max(...place.travelTimes.map(t => t.duration));
const bonus = Math.min(
MAX_POPULARITY_BONUS, // 180 s
POPULARITY_SECONDS_PER_DECADE * Math.log10(1 + reviewCount(place)) // 60 s
);
return longest + 0.5 * place.avgDuration - bonus;
};The bonus is 60 seconds per factor of ten in review count, capped at 3 minutes. A place with 1,000 reviews gets the full 3 minutes; one with 10 reviews gets about 1. That's enough to break near-ties in favour of somewhere people actually go, but not enough to send someone 10 minutes further for a famous restaurant.
2. Shortlist by fairness, then popularity
Before spending any Distance Matrix calls, I filter on straight-line distance. A place stays on the shortlist only if it makes the farthest person's trip at most 35% longer than meeting at the exact midpoint. The survivors are sorted by a popularity score that weights the rating by how many people left it:
/** Rating weighted by how many people left it: 5.0 from 3 reviews ranks below 4.5 from 3,000. */
function popularity(place: PlaceResult): number {
return (place.rating ?? 3) * Math.log10(1 + reviewCount(place));
}If fewer than 10 places pass the 35% filter, it falls back to the 10 with the smallest detour.
3. Search wider only when the midpoint is sparse
If the first search finds fewer than 6 places with at least 50 reviews, it runs a second, wider search and merges the results:
const established = found.filter(p => reviewCount(p) >= ESTABLISHED_REVIEWS).length;
if (options.radius === undefined && established < MIN_ESTABLISHED) {
const reach = farthestDistance(center, locations);
const widerRadius = Math.round(
Math.min(MAX_SEARCH_RADIUS, Math.max(searchRadius * 2.5, reach * 0.4))
);
if (widerRadius > searchRadius) {
const wider = await searchNearbyPlaces(center, widerRadius, placeTypes, apiKey);
found = mergePlaces(found, wider);
searchRadius = widerRadius;
}
}Google's Nearby Search ranks results by prominence, so a bigger circle surfaces the real neighbourhoods nearby, and the 35% filter stops them from being unfair. Busy midpoints never take this branch, so they cost the same number of API calls as before.
Testing it on real pairs
The search had no automated tests, so I compared old and new side by side. The old version came straight from git show HEAD:src/lib/meetingSearch.ts, and a short script ran both against the live Google APIs on 8 two-person pairs across Bengaluru. Here are the top suggestions, with each person's drive time:
| Pair | Before | After |
|---|---|---|
| Hebbal ↔ Kengeri | a precast cement yard (37 reviews), 33/29 min | New Shanthi Sagar (8.6k reviews), 31/32 min |
| Whitefield ↔ Electronic City | Nippu Kodi (15 reviews), 29/43 min | Folklore (486 reviews), 38/37 min |
| Bidadi ↔ Anekal | Suto Cafe (2 reviews), 40/64 min | Diletto (396 reviews), 55/46 min |
| Hoskote ↔ Electronic City | Oakwood Residence (1,960 reviews), 40/55 min | McDonald's (9,594 reviews), 47/49 min |
Two things surprised me.
The wider search mattered less than I expected. In most of the city pairs the search radius didn't change at all. Whitefield ↔ Electronic City searched 2,116 m before and after. All of the improvement there came from the shortlist and the ranking. The wider search only kicked in for the sparse pairs: Devanahalli ↔ Doddaballapur went from 2,539 m to 6,348 m, and Bidadi ↔ Anekal from 4,382 m to 10,955 m.
Fairer isn't always shorter. For Whitefield ↔ Electronic City, the total drive time went up from 72 to 75 minutes. But nobody has the 43-minute trip any more, and that's the trade the app is supposed to make.
The fix has limits. When both people are genuinely rural, like Devanahalli ↔ Doddaballapur, the picks are still small local places, because there's nothing bigger nearby. The top pick there now has 113 reviews; before, it had 1. And Google's place types are loose: the National Gallery of Modern Art came back as a restaurant or cafe result for Yelahanka ↔ JP Nagar.
I also changed the app's wording from "shortest average trip first" to "fairest trips first", and updated the home page explanation and README to match. The change is merged and deployed; every merge to main runs typecheck, lint and migrations, then deploys.
What I'd do differently
- Pick the metric from the product promise. "Nobody gets stuck with the long trip" is a min-max goal. Average travel time was never the right thing to sort by, and the bug was visible as soon as I wrote out the two-person case.
- Keep the comparison script. Running old and new code on the same fixed pairs was far more convincing than any unit test I would have written. I deleted it after the PR. Next time it goes into the repo, so the next tweak gets the same check.
- Treat the constants as guesses. 35%, 6 places, 50 reviews and 3 minutes are judgement calls tuned on 8 pairs in one city. They look right for Bengaluru; I don't know yet how they behave anywhere else.
I worked through this with a coding agent, which wrote the first version of the comparison script and ran the pairs against the APIs.