From 9bb96329139dccd35315b1aaa8bb475d97a7eb02 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 19 Jan 2018 21:51:22 -0800 Subject: [PATCH] perf improvement for db cleanup --- routes/_utils/database/cleanup.js | 3 +++ routes/_utils/database/database.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/_utils/database/cleanup.js b/routes/_utils/database/cleanup.js index e6463b5..58af9c8 100644 --- a/routes/_utils/database/cleanup.js +++ b/routes/_utils/database/cleanup.js @@ -14,6 +14,9 @@ async function cleanup(instanceName, timeline) { store.count().onsuccess = (e) => { let count = e.target.result + if (count <= MAX_NUM_STORED_STATUSES) { + return + } let openKeyCursor = index.openKeyCursor || index.openCursor openKeyCursor.call(index, null, 'prev').onsuccess = (e) => { let cursor = e.target.result diff --git a/routes/_utils/database/database.js b/routes/_utils/database/database.js index 33d3b02..c43d802 100644 --- a/routes/_utils/database/database.js +++ b/routes/_utils/database/database.js @@ -1,5 +1,5 @@ import { cleanupOldStatuses } from './cleanup' -import { OBJECT_STORE, getDatabase, doTransaction } from './shared' +import { OBJECT_STORE, getDatabase } from './shared' import { toReversePaddedBigInt, transformStatusForStorage } from './utils' export async function getTimeline(instanceName, timeline, maxId = null, limit = 20) {