Files
Tom Moor 42959d66db chore: Add cron task partitioning (#10736)
* wip

* Implementation complete

* tidying

* test

* Address feedback

* Remove duplicative retry logic from UpdateDocumentsPopularityScoreTask.
Now that we're split across many runs this is not neccessary

* Refactor to subclass, config to instance

* Refactor BaseTask to named export

* fix: Missing partition

* tsc

* Feedback
2025-11-27 16:57:52 +01:00

30 lines
758 B
TypeScript

import { Op } from "sequelize";
import documentPermanentDeleter from "@server/commands/documentPermanentDeleter";
import { Document } from "@server/models";
import { BaseTask } from "./base/BaseTask";
type Props = {
documentIds: string[];
};
export default class EmptyTrashTask extends BaseTask<Props> {
public async perform({ documentIds }: Props) {
if (!documentIds.length) {
return;
}
const documents = await Document.unscoped().findAll({
where: {
id: {
[Op.in]: documentIds,
},
// for safety, ensure the documents are in soft-delete state.
deletedAt: {
[Op.ne]: null,
},
},
paranoid: false,
});
await documentPermanentDeleter(documents);
}
}