mirror of
https://github.com/docmost/docmost.git
synced 2026-08-19 18:44:09 +08:00
index label ids on typesense
This commit is contained in:
@@ -30,7 +30,7 @@ export class LabelService {
|
|||||||
LabelType.PAGE,
|
LabelType.PAGE,
|
||||||
trx,
|
trx,
|
||||||
);
|
);
|
||||||
await this.labelRepo.addLabelToPage(pageId, label.id, trx);
|
await this.labelRepo.addLabelToPage(pageId, label.id, workspaceId, trx);
|
||||||
attached.push(label);
|
attached.push(label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
|||||||
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
||||||
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||||
import { normalizeLabelName } from '../../../core/label/utils';
|
import { normalizeLabelName } from '../../../core/label/utils';
|
||||||
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||||
|
import { EventName } from 'src/common/events/event.contants';
|
||||||
|
|
||||||
export const LabelType = {
|
export const LabelType = {
|
||||||
PAGE: 'page',
|
PAGE: 'page',
|
||||||
@@ -21,6 +23,7 @@ export class LabelRepo {
|
|||||||
constructor(
|
constructor(
|
||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
private readonly spaceMemberRepo: SpaceMemberRepo,
|
private readonly spaceMemberRepo: SpaceMemberRepo,
|
||||||
|
private readonly eventEmitter: EventEmitter2,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async findById(
|
async findById(
|
||||||
@@ -166,6 +169,7 @@ export class LabelRepo {
|
|||||||
async addLabelToPage(
|
async addLabelToPage(
|
||||||
pageId: string,
|
pageId: string,
|
||||||
labelId: string,
|
labelId: string,
|
||||||
|
workspaceId: string,
|
||||||
trx?: KyselyTransaction,
|
trx?: KyselyTransaction,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const db = dbOrTx(this.db, trx);
|
const db = dbOrTx(this.db, trx);
|
||||||
@@ -174,6 +178,11 @@ export class LabelRepo {
|
|||||||
.values({ pageId, labelId })
|
.values({ pageId, labelId })
|
||||||
.onConflict((oc) => oc.doNothing())
|
.onConflict((oc) => oc.doNothing())
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
this.eventEmitter.emit(EventName.PAGE_UPDATED, {
|
||||||
|
pageIds: [pageId],
|
||||||
|
workspaceId: workspaceId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeLabelFromPage(
|
async removeLabelFromPage(
|
||||||
@@ -197,6 +206,11 @@ export class LabelRepo {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
this.eventEmitter.emit(EventName.PAGE_UPDATED, {
|
||||||
|
pageIds: [pageId],
|
||||||
|
workspaceId: workspaceId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPageLabelCount(
|
async getPageLabelCount(
|
||||||
|
|||||||
+1
@@ -312,6 +312,7 @@ export interface PageHistory {
|
|||||||
export interface Pages {
|
export interface Pages {
|
||||||
content: Json | null;
|
content: Json | null;
|
||||||
contributorIds: Generated<string[] | null>;
|
contributorIds: Generated<string[] | null>;
|
||||||
|
labelIds: Generated<string[] | null>;
|
||||||
coverPhoto: string | null;
|
coverPhoto: string | null;
|
||||||
createdAt: Generated<Timestamp>;
|
createdAt: Generated<Timestamp>;
|
||||||
creatorId: string | null;
|
creatorId: string | null;
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: 433ed9d646...54bafd9a14
Reference in New Issue
Block a user