mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-17 17:44:09 +01:00
perf: paginate repository discovery and search
This commit is contained in:
1 parent
3fbf2cbad7
commit
0b967aa8af
11 files changed
+291
-76
No files matched your search
@@ -971,6 +971,14 @@ app.get("/api/admin/users/:username", (req, res) => {
|
||||
});
|
||||
app.post("/api/admin/users/:username/ban", (req, res) => res.json({ ok: true, reposQueued: 2 }));
|
||||
app.post("/api/admin/users/:username/:action", ok);
|
||||
app.get("/api/user/repository_picker", (req, res) => {
|
||||
const cursor = Number(req.query.cursor || 0);
|
||||
const query = String(req.query.q || "").toLowerCase();
|
||||
const repos = Array.from({ length: 63 }, (_, id) => ({ id, fullName: `research/project-${String(id + 1).padStart(2, "0")}` }));
|
||||
const matches = repos.filter(repo => repo.fullName.toLowerCase().includes(query));
|
||||
res.json({ items: matches.slice(cursor, cursor + 20), nextCursor: cursor + 20 < matches.length ? cursor + 20 : null });
|
||||
});
|
||||
|
||||
app.get("/api/user/:username/all_repositories", (req, res) => {
|
||||
const u = adminUsers.find((x) => x.username === req.params.username) || adminUsers[0];
|
||||
res.json(githubRepos(u));
|
||||
|
||||
Reference in new issue
Block a user