implement usersCountDelta in updateInstanceQueue
This commit is contained in:
parent
ad063c8637
commit
101f8f6df5
2 changed files with 6 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ export type UpdateInstanceJob = {
|
|||
latestRequestReceivedAt?: Date,
|
||||
shouldUnsuspend?: boolean,
|
||||
notesCountDelta?: number,
|
||||
usersCountDelta?: number,
|
||||
};
|
||||
|
||||
export type UpdateUserJob = {
|
||||
|
|
@ -68,12 +69,14 @@ export class CollapsedQueueService implements OnApplicationShutdown {
|
|||
latestRequestReceivedAt: maxDate(oldJob.latestRequestReceivedAt, newJob.latestRequestReceivedAt),
|
||||
shouldUnsuspend: oldJob.shouldUnsuspend || newJob.shouldUnsuspend,
|
||||
notesCountDelta: (oldJob.notesCountDelta ?? 0) + (newJob.notesCountDelta ?? 0),
|
||||
usersCountDelta: (oldJob.usersCountDelta ?? 0) + (newJob.usersCountDelta ?? 0),
|
||||
}),
|
||||
(id, job) => this.federatedInstanceService.update(id, {
|
||||
latestRequestReceivedAt: job.latestRequestReceivedAt,
|
||||
isNotResponding: job.latestRequestReceivedAt ? false : undefined,
|
||||
suspensionState: job.shouldUnsuspend ? 'none' : undefined,
|
||||
notesCount: job.notesCountDelta ? () => `"notesCount" + ${job.notesCountDelta}` : undefined,
|
||||
usersCount: job.usersCountDelta ? () => `"usersCount" + ${job.usersCountDelta}` : undefined,
|
||||
}),
|
||||
{
|
||||
onError: this.onQueueError,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import { isRetryableError } from '@/misc/is-retryable-error.js';
|
|||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { QueueService } from '@/core/QueueService.js';
|
||||
import { CollapsedQueueService } from '@/core/CollapsedQueueService.js';
|
||||
import { getApId, getApType, isActor, isCollection, isCollectionOrOrderedCollection, isPropertyValue } from '../type.js';
|
||||
import { ApLoggerService } from '../ApLoggerService.js';
|
||||
import { extractApHashtags } from './tag.js';
|
||||
|
|
@ -123,6 +124,7 @@ export class ApPersonService implements OnModuleInit {
|
|||
private readonly idService: IdService,
|
||||
private readonly timeService: TimeService,
|
||||
private readonly queueService: QueueService,
|
||||
private readonly collapsedQueueService: CollapsedQueueService,
|
||||
|
||||
apLoggerService: ApLoggerService,
|
||||
) {
|
||||
|
|
@ -576,7 +578,7 @@ export class ApPersonService implements OnModuleInit {
|
|||
// Register host
|
||||
if (this.meta.enableStatsForFederatedInstances) {
|
||||
this.federatedInstanceService.fetchOrRegister(host).then(i => {
|
||||
this.instancesRepository.increment({ id: i.id }, 'usersCount', 1);
|
||||
this.collapsedQueueService.updateInstanceQueue.enqueue(i.id, { usersCountDelta: 1 });
|
||||
if (this.meta.enableChartsForFederatedInstances) {
|
||||
this.instanceChart.newUser(i.host);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue