Skip to content

Commit 5b7d97a

Browse files
authored
Merge pull request #151 from ddxv/main
Bugfix for Search bar in menu
2 parents c8bf975 + 90f14fc commit 5b7d97a

File tree

7 files changed

+29
-53
lines changed

7 files changed

+29
-53
lines changed

backend/api_app/controllers/apps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def get_search_results(state: State, search_term: str) -> AppGroupByStore:
7979
if decoded_input[-1] == "+":
8080
decoded_input = decoded_input[:-1]
8181
df = search_apps(state, search_input=decoded_input, limit=60)
82+
logger.info(df)
83+
logger.info(df.columns)
8284
df = extend_app_icon_url(df)
8385
logger.info(f"{decoded_input=} returned rows: {df.shape[0]}")
8486
apple_apps_dict: list[AppDetail] = df[df["store"].str.startswith("Apple")].to_dict(

backend/api_app/utils.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
"""Utility functions for the api_app package."""
22

3-
import numpy as np
43
import pandas as pd
54

65

76
def extend_app_icon_url(df: pd.DataFrame) -> pd.DataFrame:
87
"""Extend the app icon url."""
9-
if "icon_url_512" in df.columns:
10-
df["app_icon_url"] = np.where(
11-
df["icon_url_100"].notna(),
12-
"https://media.appgoblin.info/app-icons/"
13-
+ df["store_id"]
14-
+ "/"
15-
+ df["icon_url_100"],
16-
df["icon_url_512"],
17-
)
18-
else:
19-
df["app_icon_url"] = np.where(
20-
df["icon_url_100"].notna(),
21-
"https://media.appgoblin.info/app-icons/"
22-
+ df["store_id"]
23-
+ "/"
24-
+ df["icon_url_100"],
25-
None,
26-
)
8+
if df.empty:
9+
df["app_icon_url"] = None
10+
return df
11+
12+
has_icon_url = df["icon_url_100"].notna()
13+
df["app_icon_url"] = None
14+
15+
if has_icon_url.any():
16+
prefix = "https://media.appgoblin.info/app-icons/"
17+
store_ids = df.loc[has_icon_url, "store_id"].astype("object")
18+
icon_paths = df.loc[has_icon_url, "icon_url_100"].astype("object")
19+
df.loc[has_icon_url, "app_icon_url"] = prefix + store_ids + "/" + icon_paths
20+
2721
return df

backend/dbcon/sql/query_search_apps.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ SELECT
3131
name,
3232
developer_name,
3333
icon_url_100,
34-
icon_url_512,
3534
featured_image_url,
3635
installs,
3736
rating,

backend/dbcon/sql/query_search_devs.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ SELECT
1818
a.store_id,
1919
a.name,
2020
a.icon_url_100,
21-
a.icon_url_512,
2221
a.featured_image_url,
2322
agml.total_installs AS installs,
2423
agml.rating,

backend/dbcon/sql/query_single_developer.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ SELECT
4747
sa.installs,
4848
sa.rating_count,
4949
sa.icon_url_100,
50-
sa.icon_url_512,
5150
sa.featured_image_url,
5251
sa.tablet_image_url_1,
5352
sa.category AS app_category,

frontend/src/routes/+layout.svelte

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import '../app.css';
33
import { page } from '$app/state';
44
import { Menu, Portal } from '@skeletonlabs/skeleton-svelte';
5-
import { invalidate } from '$app/navigation';
65
76
import IconSearch from '$lib/svg/IconSearch.svelte';
87
import MenuIcon from 'lucide-svelte/icons/menu';
@@ -12,20 +11,6 @@
1211
import LoginAccountButton from '$lib/LoginAccountButton.svelte';
1312
import NavTabs from '$lib/NavTabs.svelte';
1413
15-
import { goto } from '$app/navigation';
16-
17-
let searchTerm: string = $state('');
18-
19-
function navigateToSearch(event: any) {
20-
if (event.key === 'Enter' && searchTerm.trim() !== '') {
21-
// Replace spaces with '+'
22-
const encodedSearchTerm = encodeURIComponent(searchTerm.replace(/\s+/g, '+'));
23-
24-
// Navigate to the search route
25-
goto(`/search/${encodedSearchTerm}`);
26-
}
27-
}
28-
2914
let { children } = $props();
3015
</script>
3116

@@ -55,25 +40,23 @@
5540

5641
<AppBar.Trail class="overflow-hidden flex justify-end">
5742
<div class="flex gap-1 md:gap-2">
58-
<div class="input-group grid-cols-[auto_1fr_auto]">
59-
<div class="ig-cell preset-tonal p-2 md:p-4">
60-
<IconSearch />
61-
</div>
62-
<input
63-
class="ig-input md:hidden"
64-
type="search"
65-
placeholder="Search Apps..."
66-
bind:value={searchTerm}
67-
onkeydown={navigateToSearch}
68-
/>
43+
<form
44+
action="/search"
45+
method="GET"
46+
class="input-group grid-cols-[1fr_auto]"
47+
role="search"
48+
>
6949
<input
70-
class="ig-input hidden md:block"
50+
class="ig-input"
7151
type="search"
52+
name="term"
7253
placeholder="Search Apps & Companies"
73-
bind:value={searchTerm}
74-
onkeydown={navigateToSearch}
54+
required
7555
/>
76-
</div>
56+
<button class="ig-cell preset-tonal p-2 md:p-4" type="submit" aria-label="Search">
57+
<IconSearch />
58+
</button>
59+
</form>
7760

7861
<LoginAccountButton />
7962
</div>

frontend/src/routes/search/[term]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
1212
let { data }: Props = $props();
13-
let searchTerm: string | null = $state(page.params.term || '');
13+
const searchTerm = $derived(page.params.term || '');
1414
1515
// App store filter state
1616
type AppStore = 'apple' | 'google';

0 commit comments

Comments
 (0)