diff --git a/database/data.db b/database/data.db index 9fd718e..5b24b4c 100644 Binary files a/database/data.db and b/database/data.db differ diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index cd910cf..a720795 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -6,17 +6,19 @@ const handleUnitChange = (unit: UnitsEnum) => { $units = unit; - dropdownButton.click() + dropdownButton.click(); };
diff --git a/src/lib/db/queries.ts b/src/lib/db/queries.ts index 2f9305c..514698f 100644 --- a/src/lib/db/queries.ts +++ b/src/lib/db/queries.ts @@ -92,7 +92,7 @@ export const getWorldTemperatureStats = db.query(` WITH city_temps AS ( SELECT c.id as city_id, - c.name as city_name, + c.city as city_name, c.country_id, co.name as country_name, md.max as max_temp, diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 63fcba2..d9725cf 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -19,7 +19,19 @@ let { data, form }: PageProps = $props(); let temperatureData: HotColdCity[] | null = $state(data.temperatureData); let tempDiff: number | null = $derived( - temperatureData ? Number((Math.abs(temperatureData[0].max_temp - temperatureData[1].max_temp)).toFixed(2)) : null + temperatureData + ? Number(Math.abs(temperatureData[0].max_temp - temperatureData[1].max_temp).toFixed(2)) + : null + ); + let tempDiffImperial: number | null = $derived( + temperatureData + ? Number( + Math.abs( + celsiusToFahrenheit(temperatureData[0].max_temp) - + celsiusToFahrenheit(temperatureData[1].max_temp) + ).toFixed(2) + ) + : null ); let selectedCountryId: number | null = $state(data.country_id); let countryForm: HTMLFormElement; @@ -46,6 +58,8 @@ temperatureData = form.data; } }); + + $effect(() => console.log(tempDiff));Temperature Difference
-- {$units == UnitsEnum.IMPERIAL - ? celsiusToFahrenheit(tempDiff) - : tempDiff}{$unitsSymbol} +
+ {$units == UnitsEnum.IMPERIAL ? tempDiffImperial : tempDiff}{$unitsSymbol}