mirror of
https://github.com/yusufipk/RepoHub.git
synced 2026-09-11 10:36:07 +00:00
feat: Enhance package search with normalized name matching and remove sync:arch script.
This commit is contained in:
+2
-3
@@ -10,8 +10,7 @@
|
||||
"type-check": "tsc --noEmit",
|
||||
"test:db": "node scripts/test-db.js",
|
||||
"init:backend": "chmod +x scripts/init-backend.sh && ./scripts/init-backend.sh",
|
||||
"init:db": "node scripts/init-db.js",
|
||||
"sync:arch": "npx tsx scripts/sync-arch.ts"
|
||||
"init:db": "node scripts/init-db.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-checkbox": "^1.0.4",
|
||||
@@ -47,4 +46,4 @@
|
||||
"tailwindcss": "^3.3.0",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,9 @@ export class PackageService {
|
||||
if (search) {
|
||||
whereConditions.push(`(
|
||||
p.name ILIKE $${paramIndex} OR
|
||||
p.description ILIKE $${paramIndex}
|
||||
p.description ILIKE $${paramIndex} OR
|
||||
REPLACE(p.name, '-', ' ') ILIKE $${paramIndex} OR
|
||||
REPLACE(p.name, '-', '') ILIKE $${paramIndex}
|
||||
)`)
|
||||
values.push(`%${search}%`)
|
||||
paramIndex++
|
||||
@@ -69,7 +71,8 @@ export class PackageService {
|
||||
// 1. Exact name match
|
||||
// 2. Name starts with search term
|
||||
// 3. Name contains search term
|
||||
// 4. Description contains search term
|
||||
// 4. Normalized name matches (hyphens -> spaces, or stripped)
|
||||
// 5. Description contains search term
|
||||
// Then sort by popularity/name as tie-breaker
|
||||
orderClause = `
|
||||
ORDER BY
|
||||
@@ -77,6 +80,8 @@ export class PackageService {
|
||||
WHEN p.name ILIKE $${paramIndex} THEN 0 -- Exact match
|
||||
WHEN p.name ILIKE $${paramIndex + 1} THEN 1 -- Starts with
|
||||
WHEN p.name ILIKE $${paramIndex + 2} THEN 2 -- Contains in name
|
||||
WHEN REPLACE(p.name, '-', ' ') ILIKE $${paramIndex + 2} THEN 2 -- Normalized (space)
|
||||
WHEN REPLACE(p.name, '-', '') ILIKE $${paramIndex + 2} THEN 2 -- Normalized (strip)
|
||||
ELSE 3 -- Contains in description only
|
||||
END ASC,
|
||||
p.popularity_score DESC,
|
||||
|
||||
Reference in New Issue
Block a user