Skip to content

Commit

Permalink
Late-night amendment to autocomplete query
Browse files Browse the repository at this point in the history
Slower, but better?
  • Loading branch information
lfborjas committed Jan 28, 2021
1 parent 13583d3 commit fe6381f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Database/Queries.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ findApiKey key = do
cityAutoComplete :: Has Database sig m => Text -> Maybe Int -> m [CityQ]
cityAutoComplete q limit' = do
let limit = defaultLimit 5 limit'
query
"select * from geocode.city_autocomplete where name %> ? limit ?"
(q, limit)
query
"select * from geocode.city_autocomplete where name %> ? order by name <-> ?, population desc limit ?"
(q, q, limit)

-- | Slightly slower, but more precise, query to find a city that
-- partially matches a name: it looks at alternate names, and
Expand Down

0 comments on commit fe6381f

Please sign in to comment.