also looking at this
Migrate :text/x-text bindings to {{ }} interpolation (stx 0.2.72)
#990
50 files
+611
-371
| @@ -30,13 +30,13 @@ export default new Action({ | ||
| 30 | 30 | |
| 31 | 31 | async handle(request) { |
| 32 | 32 | const userId = request.get<number>('user_id') |
| 33 | const limit = Math.min(Math.max(request.get<number>('limit') || 100, 1), 500) | |
| 33 | const page = readPageParams(request, { defaultLimit: 100, maxLimit: 500 }) | |
| 34 | 34 | |
| 35 | 35 | try { |
| 36 | 36 | const query = userId |
| 37 | 37 | ? Activity.where('user_id', '=', userId) |
| 38 | 38 | : Activity.query() |
| 39 | const rows = (await query.orderBy('completed_at', 'desc').limit(limit).get()) ?? [] | |
| 39 | const rows = (await query.orderBy('completed_at', 'desc').get()) ?? [] | |
| 40 | 40 | |
| 41 | 41 | // Batch-load owners + trails so the feed gets names without N+1 lookups. |
| 42 | 42 | const userIds = [...new Set(rows.map((a: any) => a.user_id).filter(Boolean))] |
| @@ -71,7 +71,8 @@ export default new Action({ | ||
| 71 | 71 | } |
| 72 | 72 | }) |
| 73 | 73 | |
| 74 | return response.json({ activities, meta: { total: activities.length } }) | |
| 74 | const { items, meta } = paginate(activities, page) | |
| 75 | return response.json({ activities: items, meta }) | |
| 75 | 76 | } |
| 76 | 77 | catch (error) { |
| 77 | 78 | console.error('[activities] index failed:', error) |