Remove 4 unused database functions

This commit is contained in:
Evan Hahn 2021-05-27 11:45:45 -04:00 committed by GitHub
parent 05f9224273
commit 20e501d9f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 77 deletions

View file

@ -144,8 +144,6 @@ const dataInterface: ClientInterface = {
createOrUpdateSession, createOrUpdateSession,
createOrUpdateSessions, createOrUpdateSessions,
commitSessionsAndUnprocessed, commitSessionsAndUnprocessed,
getSessionById,
getSessionsById,
bulkAddSessions, bulkAddSessions,
removeSessionById, removeSessionById,
removeSessionsByConversation, removeSessionsByConversation,
@ -202,8 +200,6 @@ const dataInterface: ClientInterface = {
getUnprocessedCount, getUnprocessedCount,
getAllUnprocessed, getAllUnprocessed,
getUnprocessedById, getUnprocessedById,
saveUnprocessed,
saveUnprocesseds,
updateUnprocessedAttempts, updateUnprocessedAttempts,
updateUnprocessedWithData, updateUnprocessedWithData,
updateUnprocessedsWithData, updateUnprocessedsWithData,
@ -778,16 +774,6 @@ async function commitSessionsAndUnprocessed(options: {
}) { }) {
await channels.commitSessionsAndUnprocessed(options); await channels.commitSessionsAndUnprocessed(options);
} }
async function getSessionById(id: string) {
const session = await channels.getSessionById(id);
return session;
}
async function getSessionsById(id: string) {
const sessions = await channels.getSessionsById(id);
return sessions;
}
async function bulkAddSessions(array: Array<SessionType>) { async function bulkAddSessions(array: Array<SessionType>) {
await channels.bulkAddSessions(array); await channels.bulkAddSessions(array);
} }
@ -1355,16 +1341,6 @@ async function getUnprocessedById(id: string) {
return channels.getUnprocessedById(id); return channels.getUnprocessedById(id);
} }
async function saveUnprocessed(data: UnprocessedType) {
const id = await channels.saveUnprocessed(_cleanData(data));
return id;
}
async function saveUnprocesseds(arrayOfUnprocessed: Array<UnprocessedType>) {
await channels.saveUnprocesseds(_cleanData(arrayOfUnprocessed));
}
async function updateUnprocessedAttempts(id: string, attempts: number) { async function updateUnprocessedAttempts(id: string, attempts: number) {
await channels.updateUnprocessedAttempts(id, attempts); await channels.updateUnprocessedAttempts(id, attempts);
} }

View file

@ -193,8 +193,6 @@ export type DataInterface = {
sessions: Array<SessionType>; sessions: Array<SessionType>;
unprocessed: Array<UnprocessedType>; unprocessed: Array<UnprocessedType>;
}): Promise<void>; }): Promise<void>;
getSessionById: (id: string) => Promise<SessionType | undefined>;
getSessionsById: (conversationId: string) => Promise<Array<SessionType>>;
bulkAddSessions: (array: Array<SessionType>) => Promise<void>; bulkAddSessions: (array: Array<SessionType>) => Promise<void>;
removeSessionById: (id: string) => Promise<void>; removeSessionById: (id: string) => Promise<void>;
removeSessionsByConversation: (conversationId: string) => Promise<void>; removeSessionsByConversation: (conversationId: string) => Promise<void>;
@ -234,10 +232,6 @@ export type DataInterface = {
getUnprocessedCount: () => Promise<number>; getUnprocessedCount: () => Promise<number>;
getAllUnprocessed: () => Promise<Array<UnprocessedType>>; getAllUnprocessed: () => Promise<Array<UnprocessedType>>;
saveUnprocessed: (
data: UnprocessedType,
options?: { forceSave?: boolean }
) => Promise<string>;
updateUnprocessedAttempts: (id: string, attempts: number) => Promise<void>; updateUnprocessedAttempts: (id: string, attempts: number) => Promise<void>;
updateUnprocessedWithData: ( updateUnprocessedWithData: (
id: string, id: string,
@ -247,10 +241,6 @@ export type DataInterface = {
array: Array<{ id: string; data: UnprocessedUpdateType }> array: Array<{ id: string; data: UnprocessedUpdateType }>
) => Promise<void>; ) => Promise<void>;
getUnprocessedById: (id: string) => Promise<UnprocessedType | undefined>; getUnprocessedById: (id: string) => Promise<UnprocessedType | undefined>;
saveUnprocesseds: (
arrayOfUnprocessed: Array<UnprocessedType>,
options?: { forceSave?: boolean }
) => Promise<void>;
removeUnprocessed: (id: string | Array<string>) => Promise<void>; removeUnprocessed: (id: string | Array<string>) => Promise<void>;
removeAllUnprocessed: () => Promise<void>; removeAllUnprocessed: () => Promise<void>;

View file

@ -135,8 +135,6 @@ const dataInterface: ServerInterface = {
createOrUpdateSession, createOrUpdateSession,
createOrUpdateSessions, createOrUpdateSessions,
commitSessionsAndUnprocessed, commitSessionsAndUnprocessed,
getSessionById,
getSessionsById,
bulkAddSessions, bulkAddSessions,
removeSessionById, removeSessionById,
removeSessionsByConversation, removeSessionsByConversation,
@ -191,12 +189,10 @@ const dataInterface: ServerInterface = {
getUnprocessedCount, getUnprocessedCount,
getAllUnprocessed, getAllUnprocessed,
saveUnprocessed,
updateUnprocessedAttempts, updateUnprocessedAttempts,
updateUnprocessedWithData, updateUnprocessedWithData,
updateUnprocessedsWithData, updateUnprocessedsWithData,
getUnprocessedById, getUnprocessedById,
saveUnprocesseds,
removeUnprocessed, removeUnprocessed,
removeAllUnprocessed, removeAllUnprocessed,
@ -2291,27 +2287,6 @@ async function commitSessionsAndUnprocessed({
})(); })();
} }
async function getSessionById(id: string): Promise<SessionType | undefined> {
return getById(SESSIONS_TABLE, id);
}
async function getSessionsById(
conversationId: string
): Promise<Array<SessionType>> {
const db = getInstance();
const rows: JSONRows = db
.prepare<Query>(
`
SELECT json
FROM sessions
WHERE conversationId = $conversationId;
`
)
.all({
conversationId,
});
return rows.map(row => jsonToObject(row.json));
}
function bulkAddSessions(array: Array<SessionType>): Promise<void> { function bulkAddSessions(array: Array<SessionType>): Promise<void> {
return bulkAdd(SESSIONS_TABLE, array); return bulkAdd(SESSIONS_TABLE, array);
} }
@ -4041,7 +4016,7 @@ function saveUnprocessedSync(data: UnprocessedType): string {
decrypted, decrypted,
} = data; } = data;
if (!id) { if (!id) {
throw new Error('saveUnprocessed: id was falsey'); throw new Error('saveUnprocessedSync: id was falsey');
} }
prepare( prepare(
@ -4087,22 +4062,6 @@ function saveUnprocessedSync(data: UnprocessedType): string {
return id; return id;
} }
async function saveUnprocessed(data: UnprocessedType): Promise<string> {
return saveUnprocessedSync(data);
}
async function saveUnprocesseds(
arrayOfUnprocessed: Array<UnprocessedType>
): Promise<void> {
const db = getInstance();
db.transaction(() => {
for (const unprocessed of arrayOfUnprocessed) {
assertSync(saveUnprocessedSync(unprocessed));
}
})();
}
async function updateUnprocessedAttempts( async function updateUnprocessedAttempts(
id: string, id: string,
attempts: number attempts: number

View file

@ -1520,7 +1520,7 @@ describe('SignalProtocolStore', () => {
assert.strictEqual(items[2].envelope, 'third'); assert.strictEqual(items[2].envelope, 'third');
}); });
it('saveUnprocessed successfully updates item', async () => { it('can updates items', async () => {
const id = '1-one'; const id = '1-one';
await store.addUnprocessed({ await store.addUnprocessed({
id, id,