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,
createOrUpdateSessions,
commitSessionsAndUnprocessed,
getSessionById,
getSessionsById,
bulkAddSessions,
removeSessionById,
removeSessionsByConversation,
@ -202,8 +200,6 @@ const dataInterface: ClientInterface = {
getUnprocessedCount,
getAllUnprocessed,
getUnprocessedById,
saveUnprocessed,
saveUnprocesseds,
updateUnprocessedAttempts,
updateUnprocessedWithData,
updateUnprocessedsWithData,
@ -778,16 +774,6 @@ async function 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>) {
await channels.bulkAddSessions(array);
}
@ -1355,16 +1341,6 @@ async function getUnprocessedById(id: string) {
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) {
await channels.updateUnprocessedAttempts(id, attempts);
}

View file

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

View file

@ -135,8 +135,6 @@ const dataInterface: ServerInterface = {
createOrUpdateSession,
createOrUpdateSessions,
commitSessionsAndUnprocessed,
getSessionById,
getSessionsById,
bulkAddSessions,
removeSessionById,
removeSessionsByConversation,
@ -191,12 +189,10 @@ const dataInterface: ServerInterface = {
getUnprocessedCount,
getAllUnprocessed,
saveUnprocessed,
updateUnprocessedAttempts,
updateUnprocessedWithData,
updateUnprocessedsWithData,
getUnprocessedById,
saveUnprocesseds,
removeUnprocessed,
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> {
return bulkAdd(SESSIONS_TABLE, array);
}
@ -4041,7 +4016,7 @@ function saveUnprocessedSync(data: UnprocessedType): string {
decrypted,
} = data;
if (!id) {
throw new Error('saveUnprocessed: id was falsey');
throw new Error('saveUnprocessedSync: id was falsey');
}
prepare(
@ -4087,22 +4062,6 @@ function saveUnprocessedSync(data: UnprocessedType): string {
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(
id: string,
attempts: number

View file

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