mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -105,45 +105,4 @@ export class AttachmentDecayRepository {
|
||||
batch.addPrepared(AttachmentDecayById.deleteByPk({attachment_id: params.attachment_id}));
|
||||
await batch.execute();
|
||||
}
|
||||
|
||||
async fetchAllByBucket(bucket: number, limit = 200): Promise<Array<AttachmentDecayExpiryRow>> {
|
||||
const query = AttachmentDecayByExpiry.select({
|
||||
where: [AttachmentDecayByExpiry.where.eq('expiry_bucket')],
|
||||
limit,
|
||||
});
|
||||
return fetchMany<AttachmentDecayExpiryRow>(query.bind({expiry_bucket: bucket}));
|
||||
}
|
||||
|
||||
async deleteAllByBucket(bucket: number): Promise<number> {
|
||||
const records = await this.fetchAllByBucket(bucket);
|
||||
if (records.length === 0) return 0;
|
||||
const batch = new BatchBuilder();
|
||||
for (const record of records) {
|
||||
batch.addPrepared(
|
||||
AttachmentDecayByExpiry.deleteByPk({
|
||||
expiry_bucket: record.expiry_bucket,
|
||||
expires_at: record.expires_at,
|
||||
attachment_id: record.attachment_id,
|
||||
}),
|
||||
);
|
||||
batch.addPrepared(AttachmentDecayById.deleteByPk({attachment_id: record.attachment_id}));
|
||||
}
|
||||
await batch.execute();
|
||||
return records.length;
|
||||
}
|
||||
|
||||
async clearAll(days = 30): Promise<number> {
|
||||
let totalDeleted = 0;
|
||||
for (let i = 0; i < days; i++) {
|
||||
const date = new Date();
|
||||
date.setUTCDate(date.getUTCDate() - i);
|
||||
const bucket = parseInt(
|
||||
`${date.getUTCFullYear()}${String(date.getUTCMonth() + 1).padStart(2, '0')}${String(date.getUTCDate()).padStart(2, '0')}`,
|
||||
10,
|
||||
);
|
||||
const deletedInBucket = await this.deleteAllByBucket(bucket);
|
||||
totalDeleted += deletedInBucket;
|
||||
}
|
||||
return totalDeleted;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user