fix: logs for removing already existing content and paging through diff of the content
This commit is contained in:
parent
18181ed9df
commit
a40b17b141
2 changed files with 13 additions and 4 deletions
|
@ -35,8 +35,10 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|||
const { alreadyExistingInPrimary, newRevisionsInSecondary, updatedInSecondary } =
|
||||
await this.getNewRevisionsCreatedInSecondaryDatabase(userUuid)
|
||||
|
||||
this.logger.info(
|
||||
`[${dto.userUuid}] Removing ${alreadyExistingInPrimary.length} already existing revisions from secondary database`,
|
||||
)
|
||||
for (const existingRevisionUuid of alreadyExistingInPrimary) {
|
||||
this.logger.info(`[${dto.userUuid}] Removing revision ${existingRevisionUuid} from secondary database`)
|
||||
await (this.secondRevisionsRepository as RevisionRepositoryInterface).removeOneByUuid(
|
||||
Uuid.create(existingRevisionUuid).getValue(),
|
||||
userUuid,
|
||||
|
@ -214,7 +216,9 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|||
newRevisionsInSecondary: string[]
|
||||
updatedInSecondary: string[]
|
||||
}> {
|
||||
const totalRevisionsCountForUser = await this.primaryRevisionsRepository.countByUserUuid(userUuid)
|
||||
const totalRevisionsCountForUser = await (
|
||||
this.secondRevisionsRepository as RevisionRepositoryInterface
|
||||
).countByUserUuid(userUuid)
|
||||
const totalPages = Math.ceil(totalRevisionsCountForUser / this.pageSize)
|
||||
|
||||
const alreadyExistingInPrimary: string[] = []
|
||||
|
|
|
@ -36,8 +36,11 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
|
|||
const { alreadyExistingInPrimary, newItemsInSecondary, updatedInSecondary } =
|
||||
await this.getNewItemsCreatedInSecondaryDatabase(userUuid)
|
||||
|
||||
this.logger.info(
|
||||
`[${dto.userUuid}] Removing ${alreadyExistingInPrimary.length} already existing items from secondary database.`,
|
||||
)
|
||||
|
||||
for (const existingItemUuid of alreadyExistingInPrimary) {
|
||||
this.logger.info(`[${dto.userUuid}] Removing item ${existingItemUuid} from secondary database.`)
|
||||
await (this.secondaryItemRepository as ItemRepositoryInterface).removeByUuid(
|
||||
Uuid.create(existingItemUuid).getValue(),
|
||||
)
|
||||
|
@ -139,7 +142,9 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
|
|||
const updatedInSecondary: string[] = []
|
||||
const newItemsInSecondary: string[] = []
|
||||
|
||||
const totalItemsCountForUser = await this.primaryItemRepository.countAll({ userUuid: userUuid.value })
|
||||
const totalItemsCountForUser = await (this.secondaryItemRepository as ItemRepositoryInterface).countAll({
|
||||
userUuid: userUuid.value,
|
||||
})
|
||||
const totalPages = Math.ceil(totalItemsCountForUser / this.pageSize)
|
||||
for (let currentPage = 1; currentPage <= totalPages; currentPage++) {
|
||||
const query: ItemQuery = {
|
||||
|
|
Loading…
Reference in a new issue