Parallelize SQL queries
This commit is contained in:
parent
86b4da1ec2
commit
c64762858e
178 changed files with 3377 additions and 3618 deletions
|
@ -2,17 +2,16 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { omit } from 'lodash';
|
||||
import { assert } from 'chai';
|
||||
import type { Database } from '@signalapp/better-sqlite3';
|
||||
import SQL from '@signalapp/better-sqlite3';
|
||||
|
||||
import type { ReadableDB, WritableDB } from '../../sql/Interface';
|
||||
import { jsonToObject, objectToJSON, sql, sqlJoin } from '../../sql/util';
|
||||
import { updateToVersion } from './helpers';
|
||||
import { createDB, updateToVersion } from './helpers';
|
||||
import type { LegacyAttachmentDownloadJobType } from '../../sql/migrations/1040-undownloaded-backed-up-media';
|
||||
import type { AttachmentType } from '../../types/Attachment';
|
||||
import type { AttachmentDownloadJobType } from '../../types/AttachmentDownload';
|
||||
import { IMAGE_JPEG } from '../../types/MIME';
|
||||
|
||||
function getAttachmentDownloadJobs(db: Database) {
|
||||
function getAttachmentDownloadJobs(db: ReadableDB) {
|
||||
const [query] = sql`
|
||||
SELECT * FROM attachment_downloads ORDER BY receivedAt DESC;
|
||||
`;
|
||||
|
@ -31,7 +30,7 @@ type UnflattenedAttachmentDownloadJobType = Omit<
|
|||
'digest' | 'contentType' | 'size'
|
||||
>;
|
||||
function insertNewJob(
|
||||
db: Database,
|
||||
db: WritableDB,
|
||||
job: UnflattenedAttachmentDownloadJobType,
|
||||
addMessageFirst: boolean = true
|
||||
): void {
|
||||
|
@ -82,10 +81,10 @@ function insertNewJob(
|
|||
|
||||
describe('SQL/updateToSchemaVersion1040', () => {
|
||||
describe('Storing of new attachment jobs', () => {
|
||||
let db: Database;
|
||||
let db: WritableDB;
|
||||
|
||||
beforeEach(() => {
|
||||
db = new SQL(':memory:');
|
||||
db = createDB();
|
||||
updateToVersion(db, 1040);
|
||||
});
|
||||
|
||||
|
@ -338,10 +337,10 @@ describe('SQL/updateToSchemaVersion1040', () => {
|
|||
});
|
||||
|
||||
describe('existing jobs are transferred', () => {
|
||||
let db: Database;
|
||||
let db: WritableDB;
|
||||
|
||||
beforeEach(() => {
|
||||
db = new SQL(':memory:');
|
||||
db = createDB();
|
||||
updateToVersion(db, 1030);
|
||||
});
|
||||
|
||||
|
@ -462,7 +461,7 @@ describe('SQL/updateToSchemaVersion1040', () => {
|
|||
});
|
||||
|
||||
function insertLegacyJob(
|
||||
db: Database,
|
||||
db: WritableDB,
|
||||
job: Partial<LegacyAttachmentDownloadJobType>
|
||||
): void {
|
||||
db.prepare('INSERT OR REPLACE INTO messages (id) VALUES ($id)').run({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue