mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-04 21:15:45 +02:00
ジョブキューのProgressの値を正しく計算する (#16218)
* fix: ジョブキューのProgressの値の範囲を 0~100 に統一 * fix(backend): ジョブキューのProgressの計算に用いる総数を最初に一度だけ取得する
This commit is contained in:
@@ -34,6 +34,11 @@ export class CleanRemoteFilesProcessorService {
|
||||
let deletedCount = 0;
|
||||
let cursor: MiDriveFile['id'] | null = null;
|
||||
|
||||
const total = await this.driveFilesRepository.countBy({
|
||||
userHost: Not(IsNull()),
|
||||
isLink: false,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const files = await this.driveFilesRepository.find({
|
||||
where: {
|
||||
@@ -58,12 +63,7 @@ export class CleanRemoteFilesProcessorService {
|
||||
|
||||
deletedCount += 8;
|
||||
|
||||
const total = await this.driveFilesRepository.countBy({
|
||||
userHost: Not(IsNull()),
|
||||
isLink: false,
|
||||
});
|
||||
|
||||
job.updateProgress(100 / total * deletedCount);
|
||||
job.updateProgress(deletedCount * total / 100);
|
||||
}
|
||||
|
||||
this.logger.succ('All cached remote files has been deleted.');
|
||||
|
||||
@@ -43,6 +43,10 @@ export class DeleteDriveFilesProcessorService {
|
||||
let deletedCount = 0;
|
||||
let cursor: MiDriveFile['id'] | null = null;
|
||||
|
||||
const total = await this.driveFilesRepository.countBy({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const files = await this.driveFilesRepository.find({
|
||||
where: {
|
||||
@@ -67,11 +71,7 @@ export class DeleteDriveFilesProcessorService {
|
||||
deletedCount++;
|
||||
}
|
||||
|
||||
const total = await this.driveFilesRepository.countBy({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
job.updateProgress(deletedCount / total);
|
||||
job.updateProgress(deletedCount / total * 100);
|
||||
}
|
||||
|
||||
this.logger.succ(`All drive files (${deletedCount}) of ${user.id} has been deleted.`);
|
||||
|
||||
@@ -58,6 +58,10 @@ export class ExportBlockingProcessorService {
|
||||
let exportedCount = 0;
|
||||
let cursor: MiBlocking['id'] | null = null;
|
||||
|
||||
const total = await this.blockingsRepository.countBy({
|
||||
blockerId: user.id,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const blockings = await this.blockingsRepository.find({
|
||||
where: {
|
||||
@@ -97,11 +101,7 @@ export class ExportBlockingProcessorService {
|
||||
exportedCount++;
|
||||
}
|
||||
|
||||
const total = await this.blockingsRepository.countBy({
|
||||
blockerId: user.id,
|
||||
});
|
||||
|
||||
job.updateProgress(exportedCount / total);
|
||||
job.updateProgress(exportedCount / total * 100);
|
||||
}
|
||||
|
||||
stream.end();
|
||||
|
||||
@@ -95,6 +95,10 @@ export class ExportClipsProcessorService {
|
||||
let exportedClipsCount = 0;
|
||||
let cursor: MiClip['id'] | null = null;
|
||||
|
||||
const total = await this.clipsRepository.countBy({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const clips = await this.clipsRepository.find({
|
||||
where: {
|
||||
@@ -126,11 +130,7 @@ export class ExportClipsProcessorService {
|
||||
exportedClipsCount++;
|
||||
}
|
||||
|
||||
const total = await this.clipsRepository.countBy({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
job.updateProgress(exportedClipsCount / total);
|
||||
job.updateProgress(exportedClipsCount / total * 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,10 @@ export class ExportFavoritesProcessorService {
|
||||
let exportedFavoritesCount = 0;
|
||||
let cursor: MiNoteFavorite['id'] | null = null;
|
||||
|
||||
const total = await this.noteFavoritesRepository.countBy({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const favorites = await this.noteFavoritesRepository.find({
|
||||
where: {
|
||||
@@ -109,11 +113,7 @@ export class ExportFavoritesProcessorService {
|
||||
exportedFavoritesCount++;
|
||||
}
|
||||
|
||||
const total = await this.noteFavoritesRepository.countBy({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
job.updateProgress(exportedFavoritesCount / total);
|
||||
job.updateProgress(exportedFavoritesCount / total * 100);
|
||||
}
|
||||
|
||||
await write(']');
|
||||
|
||||
@@ -58,6 +58,10 @@ export class ExportMutingProcessorService {
|
||||
let exportedCount = 0;
|
||||
let cursor: MiMuting['id'] | null = null;
|
||||
|
||||
const total = await this.mutingsRepository.countBy({
|
||||
muterId: user.id,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const mutes = await this.mutingsRepository.find({
|
||||
where: {
|
||||
@@ -98,11 +102,7 @@ export class ExportMutingProcessorService {
|
||||
exportedCount++;
|
||||
}
|
||||
|
||||
const total = await this.mutingsRepository.countBy({
|
||||
muterId: user.id,
|
||||
});
|
||||
|
||||
job.updateProgress(exportedCount / total);
|
||||
job.updateProgress(exportedCount / total * 100);
|
||||
}
|
||||
|
||||
stream.end();
|
||||
|
||||
@@ -37,6 +37,8 @@ class NoteStream extends ReadableStream<Record<string, unknown>> {
|
||||
let exportedNotesCount = 0;
|
||||
let cursor: MiNote['id'] | null = null;
|
||||
|
||||
const totalPromise = notesRepository.countBy({ userId });
|
||||
|
||||
const serialize = (
|
||||
note: MiNote,
|
||||
poll: MiPoll | null,
|
||||
@@ -88,8 +90,8 @@ class NoteStream extends ReadableStream<Record<string, unknown>> {
|
||||
exportedNotesCount++;
|
||||
}
|
||||
|
||||
const total = await notesRepository.countBy({ userId });
|
||||
job.updateProgress(exportedNotesCount / total);
|
||||
const total = await totalPromise;
|
||||
job.updateProgress(exportedNotesCount / total * 100);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user