mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-12 18:43:45 +00:00
fix(#64): Address PR comments
This commit is contained in:
@@ -54,11 +54,11 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-control mt-6">
|
<div class="form-control mt-6">
|
||||||
<button class="btn btn btn-primary" on:click={signUpNewUser}>Sign Up</button>
|
<button class="btn btn-primary" on:click={signUpNewUser}>Sign Up</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<style scoped>
|
<style>
|
||||||
.card-body {
|
.card-body {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
// Format large numbers (e.g., 1000 -> 1K, 1000000 -> 1M)
|
// Format large numbers (e.g., 1000 -> 1K, 1000000 -> 1M)
|
||||||
function formatNumber(num: number): string {
|
function formatNumber(num: number): string {
|
||||||
if (num >= 1000000) {
|
if (num >= 1000000) {
|
||||||
return (num / 1000000).toFixed(1).replace(/.0$/, '') + 'M';
|
return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
|
||||||
}
|
}
|
||||||
if (num >= 1000) {
|
if (num >= 1000) {
|
||||||
return (num / 1000).toFixed(0) + 'K';
|
return (num / 1000).toFixed(0) + 'K';
|
||||||
@@ -30,9 +30,9 @@
|
|||||||
let users = '0';
|
let users = '0';
|
||||||
let livingDexesCompleted = '0';
|
let livingDexesCompleted = '0';
|
||||||
$: {
|
$: {
|
||||||
pokemonCaught = stats ? formatNumber(stats.pokemonCaught) : '0';
|
pokemonCaught = formatNumber(stats?.pokemonCaught ?? 0);
|
||||||
users = stats ? formatNumber(stats.users) : '0';
|
users = formatNumber(stats?.users ?? 0);
|
||||||
livingDexesCompleted = stats ? formatNumber(stats.livingDexesCompleted) : '0';
|
livingDexesCompleted = formatNumber(stats?.livingDexesCompleted ?? 0);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
<!-- Features Section -->
|
<!-- Features Section -->
|
||||||
<div class="py-16 bg-base-200">
|
<div class="py-16 bg-base-200">
|
||||||
<div class="container mx-auto px-4 max-w-6xl">
|
<div class="container mx-auto px-4 max-w-6xl">
|
||||||
<h1 class="text-4xl font-bold mb-12 text-center">Why Choose Living Dex Tracker?</h1>
|
<h2 class="text-4xl font-bold mb-12 text-center">Why Choose Living Dex Tracker?</h2>
|
||||||
|
|
||||||
<div class="grid md:grid-cols-2 gap-6">
|
<div class="grid md:grid-cols-2 gap-6">
|
||||||
<div class="card bg-neutral shadow-xl">
|
<div class="card bg-neutral shadow-xl">
|
||||||
@@ -318,8 +318,8 @@
|
|||||||
<div class="container mx-auto px-4 text-center">
|
<div class="container mx-auto px-4 text-center">
|
||||||
<h2 class="text-4xl font-bold mb-6">Ready to Start Your Journey?</h2>
|
<h2 class="text-4xl font-bold mb-6">Ready to Start Your Journey?</h2>
|
||||||
<p class="text-xl mb-8 text-base-content/80 max-w-2xl mx-auto">
|
<p class="text-xl mb-8 text-base-content/80 max-w-2xl mx-auto">
|
||||||
Get started today with tracking you Living Pokédex progress. It's free, open source, and built
|
Get started today with tracking your Living Pokédex progress. It's free, open source, and
|
||||||
with love for the Pokémon community.
|
built with love for the Pokémon community.
|
||||||
</p>
|
</p>
|
||||||
<div class="flex flex-wrap gap-4 justify-center">
|
<div class="flex flex-wrap gap-4 justify-center">
|
||||||
<div class="card shrink-0 w-full max-w-sm shadow-2xl bg-neutral">
|
<div class="card shrink-0 w-full max-w-sm shadow-2xl bg-neutral">
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ RETURNS TABLE (
|
|||||||
updated_at TIMESTAMPTZ
|
updated_at TIMESTAMPTZ
|
||||||
)
|
)
|
||||||
SECURITY DEFINER
|
SECURITY DEFINER
|
||||||
|
SET search_path = public, pg_temp
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
v_pokemon_caught BIGINT;
|
v_pokemon_caught BIGINT;
|
||||||
v_total_users BIGINT;
|
v_total_users BIGINT;
|
||||||
v_completed_pokedexes BIGINT;
|
v_completed_pokedexes BIGINT;
|
||||||
|
v_updated_at TIMESTAMPTZ := NOW();
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Calculate current stats: count of caught Pokémon
|
-- Calculate current stats: count of caught Pokémon
|
||||||
SELECT COUNT(*) INTO v_pokemon_caught
|
SELECT COUNT(*) INTO v_pokemon_caught
|
||||||
@@ -29,23 +31,23 @@ BEGIN
|
|||||||
-- A pokedex is completed when all its entries have caught = true
|
-- A pokedex is completed when all its entries have caught = true
|
||||||
SELECT COUNT(*) INTO v_completed_pokedexes
|
SELECT COUNT(*) INTO v_completed_pokedexes
|
||||||
FROM (
|
FROM (
|
||||||
SELECT pokedexId
|
SELECT "pokedexId"
|
||||||
FROM catch_records
|
FROM catch_records
|
||||||
GROUP BY pokedexId
|
GROUP BY "pokedexId"
|
||||||
HAVING COUNT(*) = COUNT(*) FILTER (WHERE caught = true)
|
HAVING COUNT(*) = COUNT(*) FILTER (WHERE caught = true)
|
||||||
) completed;
|
) completed;
|
||||||
|
|
||||||
-- Update cache using UPSERT pattern
|
-- Update cache using UPSERT pattern
|
||||||
INSERT INTO stats_cache (pokemon_caught, total_users, completed_pokedexes, updated_at)
|
INSERT INTO stats_cache (id, pokemon_caught, total_users, completed_pokedexes, updated_at)
|
||||||
VALUES (v_pokemon_caught, v_total_users, v_completed_pokedexes, NOW())
|
VALUES (1, v_pokemon_caught, v_total_users, v_completed_pokedexes, v_updated_at)
|
||||||
ON CONFLICT (id) DO UPDATE
|
ON CONFLICT (id) DO UPDATE
|
||||||
SET pokemon_caught = EXCLUDED.pokemon_caught,
|
SET pokemon_caught = EXCLUDED.pokemon_caught,
|
||||||
total_users = EXCLUDED.total_users,
|
total_users = EXCLUDED.total_users,
|
||||||
completed_pokedexes = EXCLUDED.completed_pokedexes,
|
completed_pokedexes = EXCLUDED.completed_pokedexes,
|
||||||
updated_at = NOW();
|
updated_at = v_updated_at;
|
||||||
|
|
||||||
-- Return the stats
|
-- Return the stats
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
SELECT v_pokemon_caught, v_total_users, v_completed_pokedexes, NOW() AS updated_at;
|
SELECT v_pokemon_caught, v_total_users, v_completed_pokedexes, v_updated_at AS updated_at;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ DECLARE
|
|||||||
v_pokemon_caught BIGINT;
|
v_pokemon_caught BIGINT;
|
||||||
v_total_users BIGINT;
|
v_total_users BIGINT;
|
||||||
v_completed_pokedexes BIGINT;
|
v_completed_pokedexes BIGINT;
|
||||||
|
v_updated_at TIMESTAMPTZ := NOW();
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Calculate current stats: count of caught Pokémon
|
-- Calculate current stats: count of caught Pokémon
|
||||||
SELECT COUNT(*) INTO v_pokemon_caught
|
SELECT COUNT(*) INTO v_pokemon_caught
|
||||||
@@ -39,17 +40,17 @@ BEGIN
|
|||||||
) completed;
|
) completed;
|
||||||
|
|
||||||
-- Update cache using UPSERT pattern
|
-- Update cache using UPSERT pattern
|
||||||
INSERT INTO stats_cache (pokemon_caught, total_users, completed_pokedexes, updated_at)
|
INSERT INTO stats_cache (id, pokemon_caught, total_users, completed_pokedexes, updated_at)
|
||||||
VALUES (v_pokemon_caught, v_total_users, v_completed_pokedexes, NOW())
|
VALUES (1, v_pokemon_caught, v_total_users, v_completed_pokedexes, v_updated_at)
|
||||||
ON CONFLICT (id) DO UPDATE
|
ON CONFLICT (id) DO UPDATE
|
||||||
SET pokemon_caught = EXCLUDED.pokemon_caught,
|
SET pokemon_caught = EXCLUDED.pokemon_caught,
|
||||||
total_users = EXCLUDED.total_users,
|
total_users = EXCLUDED.total_users,
|
||||||
completed_pokedexes = EXCLUDED.completed_pokedexes,
|
completed_pokedexes = EXCLUDED.completed_pokedexes,
|
||||||
updated_at = NOW();
|
updated_at = v_updated_at;
|
||||||
|
|
||||||
-- Return stats
|
-- Return stats
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
SELECT v_pokemon_caught, v_total_users, v_completed_pokedexes, NOW() AS updated_at;
|
SELECT v_pokemon_caught, v_total_users, v_completed_pokedexes, v_updated_at AS updated_at;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user