Skip to content

Commit

Permalink
fix years in new years
Browse files Browse the repository at this point in the history
  • Loading branch information
catdevnull committed Jan 11, 2025
1 parent 06dc7bc commit 7b14a70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
12 changes: 10 additions & 2 deletions sitio-sveltekit/src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ export const load: PageServerLoad = async ({ url, platform, setHeaders }) => {
const vuelos = await sql<Vuelo[]>`
WITH flight_data AS (
SELECT *,
(to_timestamp(json->>'stda' || ' ' || to_char(last_updated, 'YYYY'), 'DD/MM HH24:MI YYYY')::timestamp without time zone AT TIME ZONE 'America/Buenos_Aires') AS stda,
(to_timestamp(
json->>'stda' || ' ' ||
CASE
WHEN json->>'stda' LIKE '31/12%' AND split_part(json->>'x_date', '-', 2) = '01'
THEN (split_part(json->>'x_date', '-', 1)::int - 1)::text
ELSE split_part(json->>'x_date', '-', 1)
END,
'DD/MM HH24:MI YYYY'
)::timestamp without time zone AT TIME ZONE 'America/Buenos_Aires') AS stda,
CASE
WHEN LENGTH(json->>'atda') > 0 THEN (to_timestamp(json->>'atda' || ' ' || to_char(last_updated, 'YYYY'), 'DD/MM HH24:MI YYYY')::timestamp without time zone AT TIME ZONE 'America/Buenos_Aires')
WHEN LENGTH(json->>'atda') > 0 THEN (to_timestamp(json->>'atda' || ' ' || split_part(json->>'x_date', '-', 1), 'DD/MM HH24:MI YYYY')::timestamp without time zone AT TIME ZONE 'America/Buenos_Aires')
END AS atda
FROM aerolineas_latest_flight_status
left join airfleets_matriculas
Expand Down
11 changes: 0 additions & 11 deletions sitio-sveltekit/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,6 @@
</p>
</div>
</div>
{#if (dayjs(date).date() === 31 && dayjs(date).month() === 11) || (dayjs(date).date() === 1 && dayjs(date).month() === 0)}
<Alert class="mb-4">
<AlertCircleIcon class="size-4" />

<AlertTitle>Problema con los datos</AlertTitle>
<AlertDescription>
Los datos de vuelos pueden ser inexactos debido al cambio de año. Vamos a arreglarlo
eventualmente.
</AlertDescription>
</Alert>
{/if}
{:else}
<p class="mb-4 text-lg">No hay datos de vuelos para mostrar</p>
{/if}
Expand Down

0 comments on commit 7b14a70

Please sign in to comment.