From c8e7be066e1bcd87d3b2a884f1c5f26223a1f580 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 20 Apr 2022 16:33:59 +1000 Subject: [PATCH] remove messages from opengroup > 2k messages and older than 6 months --- ts/node/sql.ts | 6 +++--- ts/test/session/unit/utils/Promise_test.ts | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 4ac1faf37..60ffeec02 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -3363,7 +3363,7 @@ function cleanUpOldOpengroups() { // This is the only way we can cleanup conversations objects from users which just sent messages a while ago and with whom we never interacted. // This is only for opengroups, and is because ALL the conversations are cached in the redux store. Having a very large number of conversations (unused) is deteriorating a lot the performance of the app. // Another fix would be to not cache all the conversations in the redux store, but it ain't going to happen anytime soon as it would a pretty big change of the way we do things and would break a lot of the app. - const maxMessagePerOpengroupConvo = 1000; + const maxMessagePerOpengroupConvo = 2000; // first remove very old messages for each opengroups @@ -3373,7 +3373,7 @@ function cleanUpOldOpengroups() { if (messagesInConvo >= maxMessagePerOpengroupConvo) { const minute = 1000 * 60; - const twoMonths = minute * 60 * 24 * 60; + const sixMonths = minute * 60 * 24 * 30 * 6; console.info( `too many message: ${messagesInConvo} in convo: ${convoId}. Limit is ${maxMessagePerOpengroupConvo}` ); @@ -3382,7 +3382,7 @@ function cleanUpOldOpengroups() { ` DELETE FROM ${MESSAGES_TABLE} WHERE serverTimestamp <= $serverTimestamp AND conversationId = $conversationId` ) - .run({ conversationId: convoId, serverTimestamp: Date.now() - twoMonths }); // delete messages older than twoMonths + .run({ conversationId: convoId, serverTimestamp: Date.now() - sixMonths }); // delete messages older than sixMonths const messagesInConvoAfter = getMessagesCountByConversation(convoId); console.info( diff --git a/ts/test/session/unit/utils/Promise_test.ts b/ts/test/session/unit/utils/Promise_test.ts index e0d577ff4..c12747389 100644 --- a/ts/test/session/unit/utils/Promise_test.ts +++ b/ts/test/session/unit/utils/Promise_test.ts @@ -191,7 +191,6 @@ describe('Promise Utils', () => { await allowOnlyOneAtATime('testing', spy, 15); throw new Error('should get here'); } catch (e) { - console.warn(e); expect(e.message).to.be.be.eql('should get here'); }