mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
fix(syncing-server): select fields in query for revisions
This commit is contained in:
@@ -27,7 +27,7 @@ const fixRevisionsOwnership = async (
|
||||
|
||||
const itemsCount = await itemRepository.countAll({
|
||||
createdBetween: [createdAfter, createdBefore],
|
||||
selectString: 'item.uuid AS uuid, item.user_uuid AS userUuid',
|
||||
selectFields: ['uuid', 'userUuid'],
|
||||
contentType: [ContentType.Note, ContentType.File],
|
||||
sortOrder: 'ASC',
|
||||
sortBy: 'uuid',
|
||||
@@ -39,16 +39,17 @@ const fixRevisionsOwnership = async (
|
||||
const amountOfPages = Math.ceil(itemsCount / limit)
|
||||
const tenPercentOfPages = Math.ceil(amountOfPages / 10)
|
||||
let itemsProcessedCounter = 0
|
||||
let itemsSkippedCounter = 0
|
||||
for (let page = 1; page <= amountOfPages; page++) {
|
||||
if (page % tenPercentOfPages === 0) {
|
||||
logger.info(
|
||||
`Processing page ${page} of ${amountOfPages} items between ${createdAfter.toISOString()} and ${createdBefore.toISOString()}. Processed successfully ${itemsProcessedCounter} items.`,
|
||||
`Processing page ${page} of ${amountOfPages} items between ${createdAfter.toISOString()} and ${createdBefore.toISOString()}. Processed successfully ${itemsProcessedCounter} items. Skipped ${itemsSkippedCounter} items.`,
|
||||
)
|
||||
}
|
||||
|
||||
const items = await itemRepository.findAll({
|
||||
createdBetween: [createdAfter, createdBefore],
|
||||
selectString: 'item.uuid AS uuid, item.user_uuid AS userUuid',
|
||||
selectFields: ['uuid', 'userUuid'],
|
||||
contentType: [ContentType.Note, ContentType.File],
|
||||
offset: (page - 1) * limit,
|
||||
limit,
|
||||
@@ -58,6 +59,7 @@ const fixRevisionsOwnership = async (
|
||||
|
||||
for (const item of items) {
|
||||
if (!item.userUuid || !item.uuid) {
|
||||
itemsSkippedCounter++
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@ export type ItemQuery = {
|
||||
offset?: number
|
||||
limit?: number
|
||||
createdBetween?: Date[]
|
||||
selectString?: string
|
||||
selectFields?: string[]
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
|
||||
queryBuilder.orderBy(`item.${query.sortBy}`, query.sortOrder)
|
||||
}
|
||||
|
||||
if (query.selectString !== undefined) {
|
||||
queryBuilder.select(query.selectString)
|
||||
if (query.selectFields !== undefined) {
|
||||
queryBuilder.select(query.selectFields)
|
||||
}
|
||||
if (query.userUuid !== undefined) {
|
||||
queryBuilder.where('item.user_uuid = :userUuid', { userUuid: query.userUuid })
|
||||
|
||||
Reference in New Issue
Block a user