diff --git a/src/backend/frontpage.ts b/src/backend/frontpage.ts index 54c6b3d..c85f373 100644 --- a/src/backend/frontpage.ts +++ b/src/backend/frontpage.ts @@ -10,8 +10,8 @@ export async function getFrontpageRaw() { AND JSON_ARRAY_LENGTH(options) > 0 ORDER BY RANDOM() LIMIT 50 `); - if (!res.rows.length) return []; - return res.rows[0].frontpage_sliced; + + return res.rows; } export async function getFrontpageFullRaw() { diff --git a/src/pages/capture.js b/src/pages/capture.js index 6095d11..371ddb9 100644 --- a/src/pages/capture.js +++ b/src/pages/capture.js @@ -23,6 +23,14 @@ export async function getServerSideProps(context) { }; let frontPageForecasts = await getFrontpage(); + frontPageForecasts = frontPageForecasts.map((forecast) => ({ + ...forecast, + item: { + ...forecast.item, + timestamp: forecast.item.timestamp.toJSON(), + }, + })); + let initialResults; switch (initialQueryParameters.query != "") { case true: diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 20bd294..07af4d7 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -24,6 +24,14 @@ export async function getServerSideProps(context) { }; let frontPageForecasts = await getFrontpage(); + frontPageForecasts = frontPageForecasts.map((forecast) => ({ + ...forecast, + item: { + ...forecast.item, + timestamp: forecast.item.timestamp.toJSON(), + }, + })); + let initialResults; let props; switch ( @@ -56,27 +64,6 @@ export async function getServerSideProps(context) { }; } -/* Alternative: getStaticProps -export async function getStaticProps() { - // get frontPageForecasts somehow. - let lastUpdated = calculateLastUpdate(); // metaforecasts.find(forecast => forecast.platform == "Good Judgment Open").timestamp - let initialQueryParameters = { - query: "", - processedUrlYet: false, - starsThreshold: 2, - numDisplay: 21, // 20 - forecastsThreshold: 0, - forecastingPlatforms: platforms, - }; - return { - props: { - frontPageForecasts, - lastUpdated, - }, - }; -} -*/ - /* Body */ export default function Home({ initialResults,