Conversation
… methods for batch processing
There was a problem hiding this comment.
Pull request overview
This pull request refactors the AutoRemovePlugin by renaming configuration options for clarity, improving error messages, changing property visibility, and modifying the deletion batching logic. The PR title "Next" suggests this is part of an iterative development process.
Changes:
- Renamed
maxItemstokeepAtLeastandmaxAgetodeleteOlderThanfor better semantic clarity - Added new
minItemsKeepoption (though it's not implemented in the cleanup logic) - Removed
maxDeletePerRunoption and replaced with hardcoded batching of 100 items - Changed property visibility from protected/private to public for
resourceandtimer - Improved error messages to include resource labels and field names
- Fixed spelling errors in comments (режиму → mode, otem → item)
- Modified deletion to use Promise.all for batched parallel deletions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| types.ts | Renamed configuration options (maxItems → keepAtLeast, maxAge → deleteOlderThan), added minItemsKeep field, removed maxDeletePerRun field, fixed spelling errors in comments |
| index.ts | Updated to use renamed options, changed property visibility, improved error messages, refactored deletion logic to use Promise.all batching, removed MAX_DELETE_PER_RUN constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… comments for clarity
…eck for required createdAtField
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const limit = parseHumanNumber(this.options.keepAtLeast!); | ||
| const resource = adminforth.resource(this.resource.resourceId); | ||
|
|
||
| const allRecords = await resource.list([], null, null, [Sorts.ASC(this.options.createdAtField)]); | ||
| if (allRecords.length <= limit) return; | ||
|
|
||
| const toDelete = allRecords.slice(0, allRecords.length - limit).slice(0, this.options.maxDeletePerRun || MAX_DELETE_PER_RUN); | ||
| for (const r of toDelete) { | ||
| await resource.delete(r[this._resourceConfig.columns.find(c => c.primaryKey)!.name]); | ||
| console.log(`AutoRemovePlugin: deleted record ${r[this._resourceConfig.columns.find(c => c.primaryKey)!.name]} due to count-based limit`); | ||
| const toDelete = allRecords.slice(0, allRecords.length - limit); |
No description provided.