diff --git a/src/db/roomstore.ts b/src/db/roomstore.ts index 72677cc9b70b66cce86abdfd690a9f45f7093851..2cb9d9f0747244c069a3538a9480d966601233f8 100644 --- a/src/db/roomstore.ts +++ b/src/db/roomstore.ts @@ -156,10 +156,10 @@ export class DbRoomStore { public async getEntriesByMatrixId(matrixId: string): Promise<IRoomStoreEntry[]> { const cached = this.entriesMatrixIdCache.get(matrixId); if (cached && cached.ts + ENTRY_CACHE_LIMETIME > Date.now()) { - MetricPeg.get.storeCall("getEntriesByMatrixId", true); + MetricPeg.get.storeCall("RoomStore.getEntriesByMatrixId", true); return cached.e; } - MetricPeg.get.storeCall("getEntriesByMatrixId", false); + MetricPeg.get.storeCall("RoomStore.getEntriesByMatrixId", false); const entries = await this.db.All( "SELECT * FROM room_entries WHERE matrix_id = $id", {id: matrixId}, ); @@ -193,7 +193,7 @@ export class DbRoomStore { } public async getEntriesByMatrixIds(matrixIds: string[]): Promise<IRoomStoreEntry[]> { - MetricPeg.get.storeCall("getEntriesByMatrixIds", false); + MetricPeg.get.storeCall("RoomStore.getEntriesByMatrixIds", false); const mxIdMap = { }; matrixIds.forEach((mxId, i) => mxIdMap[i] = mxId); const sql = `SELECT * FROM room_entries WHERE matrix_id IN (${matrixIds.map((_, id) => `\$${id}`).join(", ")})`; @@ -226,7 +226,7 @@ export class DbRoomStore { } public async linkRooms(matrixRoom: MatrixStoreRoom, remoteRoom: RemoteStoreRoom) { - MetricPeg.get.storeCall("linkRooms", false); + MetricPeg.get.storeCall("RoomStore.linkRooms", false); await this.upsertRoom(remoteRoom); const values = { @@ -249,7 +249,7 @@ export class DbRoomStore { } public async getEntriesByRemoteRoomData(data: IRemoteRoomDataLazy): Promise<IRoomStoreEntry[]> { - MetricPeg.get.storeCall("getEntriesByRemoteRoomData", false); + MetricPeg.get.storeCall("RoomStore.getEntriesByRemoteRoomData", false); Object.keys(data).filter((k) => typeof(data[k]) === "boolean").forEach((k) => { data[k] = Number(data[k]); }); @@ -276,13 +276,13 @@ export class DbRoomStore { } public async removeEntriesByRemoteRoomId(remoteId: string) { - MetricPeg.get.storeCall("removeEntriesByRemoteRoomId", false); + MetricPeg.get.storeCall("RoomStore.removeEntriesByRemoteRoomId", false); await this.db.Run(`DELETE FROM room_entries WHERE remote_id = $remoteId`, {remoteId}); await this.db.Run(`DELETE FROM remote_room_data WHERE room_id = $remoteId`, {remoteId}); } public async removeEntriesByMatrixRoomId(matrixId: string) { - MetricPeg.get.storeCall("removeEntriesByMatrixRoomId", false); + MetricPeg.get.storeCall("RoomStore.removeEntriesByMatrixRoomId", false); const entries = (await this.db.All(`SELECT * FROM room_entries WHERE matrix_id = $matrixId`, {matrixId})) || []; await Util.AsyncForEach(entries, async (entry) => { if (entry.remote_id) { @@ -294,7 +294,7 @@ export class DbRoomStore { } private async upsertRoom(room: RemoteStoreRoom) { - MetricPeg.get.storeCall("upsertRoom", false); + MetricPeg.get.storeCall("RoomStore.upsertRoom", false); if (!room.data) { throw new Error("Tried to upsert a room with undefined data"); } diff --git a/src/db/userstore.ts b/src/db/userstore.ts index c85420745df27117040de49a3c2f464ee9b2b5eb..0f307d6158e527ea79dde544fd9dea8e2771add6 100644 --- a/src/db/userstore.ts +++ b/src/db/userstore.ts @@ -54,10 +54,10 @@ export class DbUserStore { public async getRemoteUser(remoteId: string): Promise<RemoteUser|null> { const cached = this.remoteUserCache.get(remoteId); if (cached && cached.ts + ENTRY_CACHE_LIMETIME > Date.now()) { - MetricPeg.get.storeCall("getRemoteUser", true); + MetricPeg.get.storeCall("UserStore.getRemoteUser", true); return cached.e; } - MetricPeg.get.storeCall("getRemoteUser", false); + MetricPeg.get.storeCall("UserStore.getRemoteUser", false); const row = await this.db.Get( "SELECT * FROM user_entries WHERE remote_id = $id", {id: remoteId}, @@ -89,7 +89,7 @@ export class DbUserStore { } public async setRemoteUser(user: RemoteUser) { - MetricPeg.get.storeCall("setRemoteUser", false); + MetricPeg.get.storeCall("UserStore.setRemoteUser", false); this.remoteUserCache.delete(user.id); const existingData = await this.db.Get( "SELECT * FROM remote_user_data WHERE remote_id = $remoteId", @@ -160,7 +160,7 @@ AND guild_id = $guild_id`, } public async linkUsers(matrixId: string, remoteId: string) { - MetricPeg.get.storeCall("linkUsers", false); + MetricPeg.get.storeCall("UserStore.linkUsers", false); // This is used ONCE in the bridge to link two IDs, so do not UPSURT data. try { await this.db.Run(`INSERT INTO user_entries VALUES ($matrixId, $remoteId)`, {