You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Chore: Migrate SQL queries in preparation for web support (#10670)
This commit is contained in:
@ -76,7 +76,7 @@ export default class Resource extends BaseItem {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||
public static fetchStatuses(resourceIds: string[]): Promise<any[]> {
|
||||
if (!resourceIds.length) return Promise.resolve([]);
|
||||
return this.db().selectAll(`SELECT resource_id, fetch_status FROM resource_local_states WHERE resource_id IN ("${resourceIds.join('","')}")`);
|
||||
return this.db().selectAll(`SELECT resource_id, fetch_status FROM resource_local_states WHERE resource_id IN ('${resourceIds.join('\',\'')}')`);
|
||||
}
|
||||
|
||||
public static sharedResourceIds(): Promise<string[]> {
|
||||
@ -107,7 +107,7 @@ export default class Resource extends BaseItem {
|
||||
}
|
||||
|
||||
public static async resetFetchErrorStatus(resourceId: string) {
|
||||
await this.db().exec('UPDATE resource_local_states SET fetch_status = ?, fetch_error = "" WHERE resource_id = ?', [Resource.FETCH_STATUS_IDLE, resourceId]);
|
||||
await this.db().exec('UPDATE resource_local_states SET fetch_status = ?, fetch_error = \'\' WHERE resource_id = ?', [Resource.FETCH_STATUS_IDLE, resourceId]);
|
||||
await this.resetOcrStatus(resourceId);
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ export default class Resource extends BaseItem {
|
||||
public static async downloadedButEncryptedBlobCount(excludedIds: string[] = null) {
|
||||
let excludedSql = '';
|
||||
if (excludedIds && excludedIds.length) {
|
||||
excludedSql = `AND resource_id NOT IN ("${excludedIds.join('","')}")`;
|
||||
excludedSql = `AND resource_id NOT IN ('${excludedIds.join('\',\'')}')`;
|
||||
}
|
||||
|
||||
const r = await this.db().selectOne(`
|
||||
@ -520,7 +520,7 @@ export default class Resource extends BaseItem {
|
||||
WHERE
|
||||
ocr_status = ? AND
|
||||
encryption_applied = 0 AND
|
||||
mime IN ("${supportedMimeTypes.join('","')}")
|
||||
mime IN ('${supportedMimeTypes.join('\',\'')}')
|
||||
`,
|
||||
params: [
|
||||
ResourceOcrStatus.Todo,
|
||||
@ -536,7 +536,7 @@ export default class Resource extends BaseItem {
|
||||
|
||||
public static async needOcr(supportedMimeTypes: string[], skippedResourceIds: string[], limit: number, options: LoadOptions): Promise<ResourceEntity[]> {
|
||||
const query = this.baseNeedOcrQuery(this.selectFields(options), supportedMimeTypes);
|
||||
const skippedResourcesSql = skippedResourceIds.length ? `AND resources.id NOT IN ("${skippedResourceIds.join('","')}")` : '';
|
||||
const skippedResourcesSql = skippedResourceIds.length ? `AND resources.id NOT IN ('${skippedResourceIds.join('\',\'')}')` : '';
|
||||
|
||||
return await this.db().selectAll(`
|
||||
${query.sql}
|
||||
@ -576,7 +576,7 @@ export default class Resource extends BaseItem {
|
||||
public static async resourceOcrTextsByIds(ids: string[]): Promise<ResourceEntity[]> {
|
||||
if (!ids.length) return [];
|
||||
ids = unique(ids);
|
||||
return this.modelSelectAll(`SELECT id, ocr_text FROM resources WHERE id IN ("${ids.join('","')}")`);
|
||||
return this.modelSelectAll(`SELECT id, ocr_text FROM resources WHERE id IN ('${ids.join('\',\'')}')`);
|
||||
}
|
||||
|
||||
public static async allForNormalization(updatedTime: number, id: string, limit = 100, options: LoadOptions = null) {
|
||||
@ -595,7 +595,7 @@ export default class Resource extends BaseItem {
|
||||
sql: `
|
||||
SELECT ${this.selectFields(options)} FROM resources
|
||||
WHERE ${whereSql}
|
||||
AND ocr_text != ""
|
||||
AND ocr_text != ''
|
||||
AND ocr_status = ?
|
||||
ORDER BY updated_time ASC, id ASC
|
||||
LIMIT ?
|
||||
|
Reference in New Issue
Block a user