fix: disable join commands on session list for performance

This commit is contained in:
Justin Lin committed 2026-10-10 00:12:30 +11:00
1 parent accfbc620c
commit 3d6eaf6b64
2 files changed
+1 -13

No files matched your search

+1 -11
View File
@@ -28,14 +28,6 @@ export async function sessionList(
}, },
}, },
{ $unwind: '$user' }, { $unwind: '$user' },
{
$lookup: {
from: 'commands',
localField: '_id',
foreignField: 'session',
as: 'commands',
},
},
pagination.sort('_id'), pagination.sort('_id'),
pagination.limit(), pagination.limit(),
]) ])
@@ -49,7 +41,6 @@ export async function sessionList(
status, status,
createdAt, createdAt,
finishedAt, finishedAt,
commands,
lastActivityAt, lastActivityAt,
} = session } = session
return { return {
@@ -65,8 +56,7 @@ export async function sessionList(
lastActivityAt && createdAt lastActivityAt && createdAt
? formatTime(lastActivityAt.getTime() - createdAt.getTime()) ? formatTime(lastActivityAt.getTime() - createdAt.getTime())
: 'N/A', // Ensure both dates are present : 'N/A', // Ensure both dates are present
commandCount: commands?.length || 0, commandCount: 0,
commands,
} }
}) })
} }
@@ -17,7 +17,6 @@
<th>Created At</th> <th>Created At</th>
<th>Finished At</th> <th>Finished At</th>
<th>Used Time</th> <th>Used Time</th>
<th>Command Count</th>
<th>Session</th> <th>Session</th>
</tr> </tr>
{{#each sessions}} {{#each sessions}}
@@ -29,7 +28,6 @@
<td>{{createdAt}}</td> <td>{{createdAt}}</td>
<td>{{finishedAt}}</td> <td>{{finishedAt}}</td>
<td>{{usedTime}}</td> <td>{{usedTime}}</td>
<td>{{commandCount}}</td>
<td><a href='/sessions/{{_id}}'>Detail</a></td> <td><a href='/sessions/{{_id}}'>Detail</a></td>
</tr> </tr>
{{/each}} {{/each}}