fix: frontpage json serialization
This commit is contained in:
parent
796d227537
commit
9714e4cd0a
|
@ -10,8 +10,8 @@ export async function getFrontpageRaw() {
|
||||||
AND JSON_ARRAY_LENGTH(options) > 0
|
AND JSON_ARRAY_LENGTH(options) > 0
|
||||||
ORDER BY RANDOM() LIMIT 50
|
ORDER BY RANDOM() LIMIT 50
|
||||||
`);
|
`);
|
||||||
if (!res.rows.length) return [];
|
|
||||||
return res.rows[0].frontpage_sliced;
|
return res.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getFrontpageFullRaw() {
|
export async function getFrontpageFullRaw() {
|
||||||
|
|
|
@ -23,6 +23,14 @@ export async function getServerSideProps(context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let frontPageForecasts = await getFrontpage();
|
let frontPageForecasts = await getFrontpage();
|
||||||
|
frontPageForecasts = frontPageForecasts.map((forecast) => ({
|
||||||
|
...forecast,
|
||||||
|
item: {
|
||||||
|
...forecast.item,
|
||||||
|
timestamp: forecast.item.timestamp.toJSON(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
let initialResults;
|
let initialResults;
|
||||||
switch (initialQueryParameters.query != "") {
|
switch (initialQueryParameters.query != "") {
|
||||||
case true:
|
case true:
|
||||||
|
|
|
@ -24,6 +24,14 @@ export async function getServerSideProps(context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let frontPageForecasts = await getFrontpage();
|
let frontPageForecasts = await getFrontpage();
|
||||||
|
frontPageForecasts = frontPageForecasts.map((forecast) => ({
|
||||||
|
...forecast,
|
||||||
|
item: {
|
||||||
|
...forecast.item,
|
||||||
|
timestamp: forecast.item.timestamp.toJSON(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
let initialResults;
|
let initialResults;
|
||||||
let props;
|
let props;
|
||||||
switch (
|
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 */
|
/* Body */
|
||||||
export default function Home({
|
export default function Home({
|
||||||
initialResults,
|
initialResults,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user