Fix call history read syncs
This commit is contained in:
parent
688de5a99b
commit
5a5b681b51
7 changed files with 187 additions and 46 deletions
|
@ -19,7 +19,8 @@ describe('SQL/updateToSchemaVersion1100', () => {
|
|||
let db: WritableDB;
|
||||
beforeEach(() => {
|
||||
db = createDB();
|
||||
updateToVersion(db, 1100);
|
||||
// index updated in 1170
|
||||
updateToVersion(db, 1170);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -29,14 +30,26 @@ describe('SQL/updateToSchemaVersion1100', () => {
|
|||
describe('Optimize markAllCallHistoryReadInConversation', () => {
|
||||
it('is fast', () => {
|
||||
const COUNT = 10_000;
|
||||
const CONVERSATIONS = 30;
|
||||
|
||||
const conversations = Array.from(
|
||||
{ length: CONVERSATIONS },
|
||||
(_, index) => {
|
||||
return {
|
||||
id: `test-conversation-${index}`,
|
||||
groupId: `test-conversation-${index}`,
|
||||
serviceId: `test-conversation-${index}`,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const messages = Array.from({ length: COUNT }, (_, index) => {
|
||||
return {
|
||||
id: `test-message-${index}`,
|
||||
type: 'call-history',
|
||||
seenStatus: SeenStatus.Unseen,
|
||||
conversationId: `test-conversation-${index % 30}`,
|
||||
sent_at: index,
|
||||
conversationId: `test-conversation-${index % CONVERSATIONS}`,
|
||||
received_at: index,
|
||||
json: {
|
||||
callId: `test-call-${index}`,
|
||||
},
|
||||
|
@ -46,7 +59,7 @@ describe('SQL/updateToSchemaVersion1100', () => {
|
|||
const callsHistory = Array.from({ length: COUNT }, (_, index) => {
|
||||
return {
|
||||
callId: `test-call-${index}`,
|
||||
peerId: `test-conversation-${index % 30}`,
|
||||
peerId: `test-conversation-${index % CONVERSATIONS}`,
|
||||
timestamp: index,
|
||||
ringerId: null,
|
||||
mode: CallMode.Direct,
|
||||
|
@ -56,6 +69,7 @@ describe('SQL/updateToSchemaVersion1100', () => {
|
|||
};
|
||||
});
|
||||
|
||||
insertData(db, 'conversations', conversations);
|
||||
insertData(db, 'messages', messages);
|
||||
insertData(db, 'callsHistory', callsHistory);
|
||||
|
||||
|
@ -72,8 +86,9 @@ describe('SQL/updateToSchemaVersion1100', () => {
|
|||
};
|
||||
|
||||
const start = performance.now();
|
||||
markAllCallHistoryRead(db, target, true);
|
||||
const changes = markAllCallHistoryRead(db, target, true);
|
||||
const end = performance.now();
|
||||
assert.equal(changes, Math.ceil(COUNT / CONVERSATIONS));
|
||||
assert.isBelow(end - start, 50);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue