Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Oct 24, 2021
1 parent d4a0322 commit 643bddf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/server/src/models/ChangeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ export default class ChangeModel extends BaseModel<Change> {
logger.info(`deleteOldChanges: Processing changes older than: ${formatDateTime(cutOffDate)} (${cutOffDate})`);

while (true) {
// First get all the UPDATE changes before the specified date, and
// order by the items that had the most changes. Also for each item
// get the most recent change date from within that time interval,
// as we need this below.

const changeReport: ChangeReportItem[] = await this
.db(this.tableName)

Expand Down Expand Up @@ -354,6 +359,9 @@ export default class ChangeModel extends BaseModel<Change> {
return;
}

// Still from within the specified interval, delete all
// UPDATE changes, except for the most recent one.

const deletedCount = await this
.db(this.tableName)
.where('type', '=', ChangeType.Update)
Expand All @@ -367,12 +375,12 @@ export default class ChangeModel extends BaseModel<Change> {
}
}, 'ChangeModel::deleteOldChanges');

logger.info(`deleteOldChanges: Processed: ${doneItemIds.length} items. Deleted: ${totalDeletedCount}`);
logger.info(`deleteOldChanges: Processed: ${doneItemIds.length} items. Deleted: ${totalDeletedCount} changes.`);

if (error) throw error;
}

logger.info(`deleteOldChanges: Finished processing. Done ${doneItemIds.length} items. Deleted: ${totalDeletedCount}`);
logger.info(`deleteOldChanges: Finished processing. Done ${doneItemIds.length} items. Deleted: ${totalDeletedCount} changes.`);
}

public async save(change: Change, options: SaveOptions = {}): Promise<Change> {
Expand Down

0 comments on commit 643bddf

Please sign in to comment.