Skip to content

Commit

Permalink
fix: add primitive types to levenshtein
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Aug 1, 2024
1 parent 7f89297 commit ec05978
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion apps/backend/src/backend/postgres/queries.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,20 @@ pub fn upsert_package_type_fun_signature(
}

pub fn find_similar_type_names(db: pgo.Connection, name: String) {
"SELECT DISTINCT ON (name) name
"SELECT *
FROM (VALUES
('Int'),
('Float'),
('String'),
('Bool'),
('List'),
('Nil'),
('Result'),
('BitArray')
) AS t (name)
WHERE levenshtein_less_equal(name, 'Int', 2) <= 2
UNION
SELECT DISTINCT ON (name) name
FROM package_type_fun_signature
WHERE (kind = 'type_definition' OR kind = 'type_alias')
AND levenshtein_less_equal(name, $1, 2) <= 2"
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/backend/router.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn search(query: String, ctx: Context) {

let exact_type_searches =
option.then(ctx.type_search_subject, fn(subject) {
process.try_call(subject, type_search.Find(_, query), within: 10_000)
process.try_call(subject, type_search.Find(_, query), within: 15_000)
|> option.from_result
|> option.flatten
})
Expand Down

0 comments on commit ec05978

Please sign in to comment.