mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 15:15:24 +00:00
fix(database): batch session activity persistence (#1539)
This commit is contained in:
1 parent
dc5d57c012
commit
c78bc37eb2
6 files changed
+110
-3
No files matched your search
@@ -13,6 +13,8 @@ export class SessionRepository {
|
||||
constructor(
|
||||
private readonly context: DatabaseContext,
|
||||
private readonly onWrite?: () => void | Promise<void>,
|
||||
private readonly onActivity:
|
||||
(() => void | Promise<void>) | undefined = onWrite,
|
||||
) {}
|
||||
|
||||
async create(session: NewSessionRecord): Promise<SessionRecord> {
|
||||
@@ -63,7 +65,7 @@ export class SessionRepository {
|
||||
.where(and(eq(sessions.id, id), lte(sessions.lastActiveAt, cutoff)));
|
||||
|
||||
if (rowsAffected(result) === 0) return false;
|
||||
await this.afterWrite();
|
||||
await this.onActivity?.();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user