mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-27 15:05:38 -04:00
[admin][optim] only load reports up to 3 months ago
This commit is contained in:
parent
1da4fa2bb0
commit
c2805aa1de
@ -12,6 +12,7 @@ import buildLocaleList from "../../src/buildLocaleList";
|
|||||||
import {archiveBan, liftBan} from "../ban";
|
import {archiveBan, liftBan} from "../ban";
|
||||||
import marked from 'marked';
|
import marked from 'marked';
|
||||||
import {loadCurrentUser} from "./user";
|
import {loadCurrentUser} from "./user";
|
||||||
|
import {encodeTime} from "ulid";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
@ -190,12 +191,15 @@ router.get('/admin/reports', handleErrorAsync(async (req, res) => {
|
|||||||
return res.status(401).json({error: 'Unauthorised'});
|
return res.status(401).json({error: 'Unauthorised'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cutoff = encodeTime(Date.now() - 3*31*24*60*60*1000, 10) + '0'.repeat(16);
|
||||||
|
|
||||||
return res.json(await req.db.all(SQL`
|
return res.json(await req.db.all(SQL`
|
||||||
SELECT reports.id, group_concat(p.locale) as profiles, sus.username AS susUsername, reporter.username AS reporterUsername, reports.comment, reports.isAutomatic, reports.isHandled
|
SELECT reports.id, group_concat(p.locale) as profiles, sus.username AS susUsername, reporter.username AS reporterUsername, reports.comment, reports.isAutomatic, reports.isHandled
|
||||||
FROM reports
|
FROM reports
|
||||||
LEFT JOIN users sus ON reports.userId = sus.id
|
LEFT JOIN users sus ON reports.userId = sus.id
|
||||||
LEFT JOIN users reporter ON reports.reporterId = reporter.id
|
LEFT JOIN users reporter ON reports.reporterId = reporter.id
|
||||||
LEFT JOIN profiles p on sus.id = p.userId
|
LEFT JOIN profiles p on sus.id = p.userId
|
||||||
|
WHERE reports.id > ${cutoff}
|
||||||
GROUP BY reports.id
|
GROUP BY reports.id
|
||||||
ORDER BY min(reports.isHandled) ASC, reports.id DESC
|
ORDER BY min(reports.isHandled) ASC, reports.id DESC
|
||||||
`));
|
`));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user