Skip to content

Commit

Permalink
opinion publica prototipo 1
Browse files Browse the repository at this point in the history
  • Loading branch information
catdevnull committed Feb 29, 2024
1 parent df6b5ba commit 8de4949
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
build
.svelte-kit
package
.env
.env.*
!.env.example
Expand Down
1 change: 1 addition & 0 deletions sitio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"db:generate": "drizzle-kit generate:sqlite"
},
"dependencies": {
"@bybas/weather-icons": "^2.0.0",
"@fontsource-variable/inter": "^5.0.16",
"@libsql/client": "^0.5.2",
"boring-name-generator": "^1.0.3",
Expand Down
44 changes: 43 additions & 1 deletion sitio/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { db } from "$lib/db";
import { desc, isNotNull } from "drizzle-orm";
import { scraps } from "../../../../schema";
import type { PageServerLoad } from "./$types";
import { queryLastWeek } from "$lib/data-processing/queryWeekly";

export const load: PageServerLoad = async ({ setHeaders }) => {
const t0 = performance.now();
const [lastUpdated, ultimaSemana] = await Promise.all([
db.query.scraps.findFirst({
orderBy: desc(scraps.at),
where: isNotNull(scraps.totalTweetsSeen),
}),
queryLastWeek(),
]);
const t1 = performance.now();
console.log("lastUpdated+ultimaSemana", t1 - t0);

setHeaders({
"cache-control": "public, max-age=60",
});

return {
lastUpdated,
ultimaSemana,
};
};
74 changes: 74 additions & 0 deletions sitio/src/routes/experimentos/opinion-publica/placa-1/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<script lang="ts">
import { dayjs } from "$lib/consts";
import { formatTinyDurationFromMs } from "$lib/data-processing/screenTime";
import type { PageData } from "./$types";
import ClearDay from "@bybas/weather-icons/production/fill/all/clear-day.svg";
import Cloudy from "@bybas/weather-icons/production/fill/all/cloudy.svg";
import Thunder from "@bybas/weather-icons/production/fill/all/thunderstorms-rain.svg";
export let data: PageData;
const tz = "America/Argentina/Buenos_Aires";
const weekDayFormatter = Intl.DateTimeFormat("es-AR", {
day: "2-digit",
weekday: "short",
timeZone: tz,
});
$: days = data.ultimaSemana.map((s) => s.day);
$: tweets = data.ultimaSemana.map((s) => s.tweets);
$: retweets = data.ultimaSemana.map((s) => s.retweets);
$: screenTime = data.ultimaSemana.map((s) => s.screenTime);
</script>

<!-- d83926 -->

<div class="min-h-screen w-screen bg-[#5ea1b4] font-bold text-black">
<h1 class="px-8 py-24 text-center text-7xl font-extrabold">
El pronóstico de Milei en Twitter
</h1>

<table class="mx-auto text-center text-4xl">
<tbody>
<tr>
{#each days as day}
<th class="p-4">
{weekDayFormatter.format(
dayjs(day, "YYYY-MM-DD").tz(tz, true).toDate(),
)}
</th>
{/each}
</tr>
<tr>
{#each tweets as tweets}
<td class="p-4">
{#if tweets.length < 300}
<img src={ClearDay} />
{:else if tweets.length < 550}
<img src={Cloudy} />
{:else}
<img src={Thunder} />
{/if}
</td>
{/each}
</tr>
<tr>
{#each tweets as tweets}
<td class="p-4">{tweets.length}❤️</td>
{/each}
</tr>
<tr>
{#each retweets as retweets}
<td class="p-4">{retweets.length}🔁</td>
{/each}
</tr>
<tr>
{#each screenTime as screenTime}
<td class="p-4">
{formatTinyDurationFromMs(screenTime)}
</td>
{/each}
</tr>
</tbody>
</table>
</div>

0 comments on commit 8de4949

Please sign in to comment.