18 lines
501 B
JavaScript
18 lines
501 B
JavaScript
|
import models from '../../api/models'
|
||
|
|
||
|
export default async (_, res) => {
|
||
|
// get the latest daily discussion thread
|
||
|
// this should probably be made more generic
|
||
|
// eg if the title changes this will break
|
||
|
// ... but this will need to change when we have more subs anyway
|
||
|
const [{ id }] = await models.$queryRaw(`
|
||
|
SELECT id
|
||
|
FROM "Item"
|
||
|
WHERE "pinId" IS NOT NULL
|
||
|
AND title = 'Daily discussion thread'
|
||
|
ORDER BY created_at DESC
|
||
|
LIMIT 1`)
|
||
|
|
||
|
res.redirect(`/items/${id}`)
|
||
|
}
|