mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor(server): remove unused randomDoc method (#10985)
close CLOUD-177
This commit is contained in:
@@ -2,7 +2,6 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import { chunk } from 'lodash-es';
|
||||
|
||||
import {
|
||||
Cache,
|
||||
DocHistoryNotFound,
|
||||
DocNotFound,
|
||||
EventBus,
|
||||
@@ -22,7 +21,6 @@ import {
|
||||
HistoryFilter,
|
||||
} from '../storage';
|
||||
|
||||
const UPDATES_QUEUE_CACHE_KEY = 'doc:manager:updates';
|
||||
declare global {
|
||||
interface Events {
|
||||
'doc.snapshot.deleted': {
|
||||
@@ -50,7 +48,6 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
|
||||
constructor(
|
||||
private readonly models: Models,
|
||||
private readonly mutex: Mutex,
|
||||
private readonly cache: Cache,
|
||||
private readonly event: EventBus,
|
||||
protected override readonly options: DocStorageOptions,
|
||||
private readonly queue: JobQueue
|
||||
@@ -377,35 +374,4 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
|
||||
protected async lastDocHistory(workspaceId: string, id: string) {
|
||||
return this.models.history.getLatest(workspaceId, id);
|
||||
}
|
||||
|
||||
// for auto merging
|
||||
async randomDoc() {
|
||||
const key = await this.cache.mapRandomKey(UPDATES_QUEUE_CACHE_KEY);
|
||||
|
||||
if (key) {
|
||||
const cachedCount = await this.cache.mapIncrease(
|
||||
UPDATES_QUEUE_CACHE_KEY,
|
||||
key,
|
||||
0
|
||||
);
|
||||
|
||||
if (cachedCount > 0) {
|
||||
const [workspaceId, id] = key.split('::');
|
||||
const count = await this.models.doc.getUpdateCount(workspaceId, id);
|
||||
|
||||
// FIXME(@forehalo): somehow the update count in cache is not accurate
|
||||
if (count === 0) {
|
||||
metrics.doc
|
||||
.counter('doc_update_count_inconsistent_with_cache')
|
||||
.add(1);
|
||||
await this.cache.mapDelete(UPDATES_QUEUE_CACHE_KEY, key);
|
||||
return null;
|
||||
}
|
||||
|
||||
return { workspaceId, docId: id };
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user