diff --git a/src/backend/frontpage.ts b/src/backend/frontpage.ts index b339a4b..705da30 100644 --- a/src/backend/frontpage.ts +++ b/src/backend/frontpage.ts @@ -2,22 +2,18 @@ import { pgRead, readWritePool } from "./database/pg-wrapper"; import { Forecast } from "./platforms"; export async function getFrontpage(): Promise { - const client = await readWritePool.connect(); - const res = await client.query( + const res = await readWritePool.query( "SELECT frontpage_sliced FROM frontpage ORDER BY id DESC LIMIT 1" ); if (!res.rows.length) return []; - console.log(res.rows[0].frontpage_sliced); return res.rows[0].frontpage_sliced; } export async function getFrontpageFull(): Promise { - const client = await readWritePool.connect(); - const res = await client.query( + const res = await readWritePool.query( "SELECT frontpage_full FROM frontpage ORDER BY id DESC LIMIT 1" ); if (!res.rows.length) return []; - console.log(res.rows[0]); return res.rows[0].frontpage_full; } @@ -26,9 +22,8 @@ export async function rebuildFrontpage() { tableName: "questions", }); - const client = await readWritePool.connect(); const frontpageSliced = ( - await client.query(` + await readWritePool.query(` SELECT * FROM questions WHERE (qualityindicators->>'stars')::int >= 3 @@ -39,7 +34,7 @@ export async function rebuildFrontpage() { ).rows; const start = Date.now(); - await client.query( + await readWritePool.query( "INSERT INTO frontpage(frontpage_full, frontpage_sliced) VALUES($1, $2)", [JSON.stringify(frontpageFull), JSON.stringify(frontpageSliced)] ); diff --git a/src/pages/api/frontpage.ts b/src/pages/api/frontpage.ts index d4a3b96..0611498 100644 --- a/src/pages/api/frontpage.ts +++ b/src/pages/api/frontpage.ts @@ -7,7 +7,5 @@ export default async function handler( res: NextApiResponse ) { let frontpageElements = await getFrontpage(); - console.log(frontpageElements.map((element) => element.title).slice(0, 5)); - console.log("..."); res.status(200).json(frontpageElements); }