Skip to content

Commit

Permalink
fix: search fixes
Browse files Browse the repository at this point in the history
- search author now works
- failed searches now simply clear the search instead of redirecting you to the main page
  • Loading branch information
Torwent committed Jun 13, 2023
1 parent 6795646 commit 2e859a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/routes/devs/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export const load: PageLoad = async ({ url, depends }) => {
.select("real_name, username, description, github, paypal_id, content", {
count: "exact"
})
.ilike("id_realname_username_description_content", "%" + search + "%")
.ilike("search_devs", "%" + search + "%")
}

const { data, count, error } = devsData

if (error) {
console.error(error)
throw redirect(303, "/")
throw redirect(303, "/devs")
}
const devs = data

Expand Down
8 changes: 3 additions & 5 deletions src/routes/scripts/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ export const load: Load = async ({ url, depends }) => {
`id, title, description, content, categories, subcategories, published, min_xp, max_xp, min_gp, max_gp,
scripts_protected (author, assets_path, author_id, assets_alt, revision),
stats_scripts (experience, gold, runtime, levels, total_unique_users, total_current_users, total_monthly_users)`,
{
count: "exact"
}
{ count: "exact" }
)
.contains("categories", categoriesFilters)
.contains("subcategories", subcategoriesFilters)
.ilike("scripts_public_search", "%" + search + "%")
.ilike("search_script", "%" + search + "%")
}

const promises = await Promise.all([
Expand All @@ -67,7 +65,7 @@ export const load: Load = async ({ url, depends }) => {

if (error) {
console.error(error)
throw redirect(303, "/")
throw redirect(303, "/scripts")
}

const scriptData = data as unknown as Script[]
Expand Down
4 changes: 2 additions & 2 deletions src/routes/tutorials/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export const load: PageLoad = async ({ url, depends, parent }) => {
.select("id, created_at, user_id, author, title, description, content, level", {
count: "exact"
})
.ilike("tutorials_search", "%" + search.replaceAll("%", "") + "%")
.ilike("search_tutorials", "%" + search.replaceAll("%", "") + "%")
}

const { data, count, error } = await postsData

if (error) {
console.error("tutorials SELECT failed: " + error)
throw redirect(303, "./")
throw redirect(303, "/tutorials")
}

const posts = data
Expand Down

0 comments on commit 2e859a3

Please sign in to comment.