File tree Expand file tree Collapse file tree 4 files changed +15
-31
lines changed
Expand file tree Collapse file tree 4 files changed +15
-31
lines changed Original file line number Diff line number Diff line change 1- import type { connectDb } from "$lib/db/connectDb" ;
21import type { Dayjs } from "dayjs" ;
32import {
43 likedTweets ,
@@ -16,6 +15,7 @@ import {
1615} from "./screenTime" ;
1716import { formatDuration } from "date-fns" ;
1817import { es } from "date-fns/locale/es" ;
18+ import { type db as dbGlobal } from "@/db" ;
1919
2020export function makeMapOfDays < T > (
2121 days : Array < Date > ,
@@ -42,7 +42,7 @@ export function makeMapOfDays<T>(
4242}
4343
4444export async function getDataForTimePeriod (
45- db : Awaited < ReturnType < typeof connectDb > > ,
45+ db : typeof dbGlobal ,
4646 start : Dayjs ,
4747 end : Dayjs ,
4848) : Promise < [ Array < MiniLikedTweet > , Array < MiniRetweet > ] > {
@@ -76,7 +76,7 @@ export async function getDataForTimePeriod(
7676}
7777
7878export async function getStatsForDaysInTimePeriod (
79- db : Awaited < ReturnType < typeof connectDb > > ,
79+ db : typeof dbGlobal ,
8080 start : Dayjs ,
8181 end : Dayjs ,
8282) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import * as schema from "../../schema" ;
12import { env } from "$env/dynamic/private" ;
2- import { connectDb } from "./connectDb.js" ;
3+ import postgres from "postgres" ;
4+ import { drizzle } from "drizzle-orm/postgres-js" ;
35
46const path = env . DATABASE_URL ?? "postgresql://localhost:5432/milei" ;
5- export const db = connectDb ( {
6- url : path ,
7+
8+ const client = postgres ( path , {
9+ max : 1 ,
10+ idle_timeout : 20 ,
11+ connect_timeout : 10 ,
712} ) ;
13+
14+ export const db = drizzle ( client , { schema : schema } ) ;
Original file line number Diff line number Diff line change @@ -2,15 +2,13 @@ import { parsearLinkDeTwitter } from "$lib/consts";
22import { readFile } from "node:fs/promises" ;
33import { promisify } from "node:util" ;
44import { brotliDecompress } from "node:zlib" ;
5- import { connectDb } from "./connectDb" ;
65import * as schema from "../../schema" ;
76import { toDate } from "date-fns-tz" ;
7+ import type { db } from "." ;
88
99const brotliDecompressP = promisify ( brotliDecompress ) ;
1010
11- export async function seedHistoricLikes (
12- db : Awaited < ReturnType < typeof connectDb > > ,
13- ) {
11+ export async function seedHistoricLikes ( db : typeof db ) {
1412 console . time ( "seedHistoricLikes" ) ;
1513 const compressed = await readFile ( "src/lib/db/historicLikes/likes.tsv.br" ) ;
1614 const dataset = await brotliDecompressP ( compressed ) ;
You can’t perform that action at this time.
0 commit comments