chore: updated resolve route 70704d0d
Steve · 2026-01-24 10:05 1 file(s) · +21 −7
packages/server/src/routes/admin.ts +21 −7
9 9
		const db = c.env.DB;
10 10
		const queue = c.env.RESOLUTION_QUEUE;
11 11
12 -
		// Get all records from repo_records
13 -
		const { results } = await db
14 -
			.prepare(
15 -
				`SELECT did, rkey FROM repo_records
16 -
         WHERE collection = 'site.standard.document'`,
17 -
			)
18 -
			.all<{ did: string; rkey: string }>();
12 +
		// Get limit from query params (default to 100 for safety)
13 +
		const limitParam = c.req.query("limit");
14 +
		const limit = limitParam ? parseInt(limitParam, 10) : 100;
15 +
16 +
		// Get records from repo_records
17 +
		const query =
18 +
			limit > 0
19 +
				? `SELECT did, rkey FROM repo_records
20 +
         WHERE collection = 'site.standard.document'
21 +
         ORDER BY synced_at DESC
22 +
         LIMIT ?`
23 +
				: `SELECT did, rkey FROM repo_records
24 +
         WHERE collection = 'site.standard.document'`;
25 +
26 +
		const { results } =
27 +
			limit > 0
28 +
				? await db
29 +
						.prepare(query)
30 +
						.bind(limit)
31 +
						.all<{ did: string; rkey: string }>()
32 +
				: await db.prepare(query).all<{ did: string; rkey: string }>();
19 33
20 34
		if (!results || results.length === 0) {
21 35
			return c.json({ message: "No documents to process", queued: 0 });