Skip to content

Commit e07e98c

Browse files
committed
Add EngagementFilters.engagedName
1 parent de3283a commit e07e98c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/components/engagement/dto/list-engagements.dto.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export abstract class EngagementFilters {
2727

2828
@Field({
2929
nullable: true,
30+
description:
31+
'Only engagements whose project or engaged entity (language / user) name match',
3032
})
3133
readonly name?: string;
3234

@@ -39,6 +41,13 @@ export abstract class EngagementFilters {
3941
@FilterField(() => ProjectFilters)
4042
readonly project?: ProjectFilters & {};
4143

44+
@Field({
45+
nullable: true,
46+
description:
47+
'Only engagements whose engaged entity (language / user) name match',
48+
})
49+
readonly engagedName?: string;
50+
4251
readonly languageId?: ID;
4352
@FilterField(() => LanguageFilters)
4453
readonly language?: LanguageFilters & {};

src/components/engagement/engagement.repository.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ export class EngagementRepository extends CommonRepository {
519519
@OnIndex('schema')
520520
private async createSchemaIndexes() {
521521
await this.db.query().apply(NameIndex.create()).run();
522+
await this.db.query().apply(EngagedNameIndex.create()).run();
522523
await this.db.query().apply(LanguageNameIndex.create()).run();
523524
await this.db.query().apply(InternshipNameIndex.create()).run();
524525
}
@@ -553,6 +554,22 @@ export const engagementFilters = filter.define(() => EngagementFilters, {
553554
separateQueryForEachWord: true,
554555
minScore: 0.9,
555556
}),
557+
engagedName: filter.fullText({
558+
index: () => EngagedNameIndex,
559+
matchToNode: (q) =>
560+
q.match([
561+
node('node', 'Engagement'),
562+
relation('out', '', undefined, ACTIVE),
563+
node('', 'BaseNode'),
564+
relation('out', '', undefined, ACTIVE),
565+
node('match'),
566+
]),
567+
// Treat each word as a separate search term
568+
// Each word could point to a different node
569+
// i.e. "first - last"
570+
separateQueryForEachWord: true,
571+
minScore: 0.9,
572+
}),
556573
projectId: filter.pathExists((id) => [
557574
node('node'),
558575
relation('in', '', 'engagement'),
@@ -724,6 +741,12 @@ const NameIndex = FullTextIndex({
724741
properties: 'value',
725742
analyzer: 'standard-folding',
726743
});
744+
const EngagedNameIndex = FullTextIndex({
745+
indexName: 'EngagedName',
746+
labels: ['LanguageName', 'LanguageDisplayName', 'UserName'],
747+
properties: 'value',
748+
analyzer: 'standard-folding',
749+
});
727750
const LanguageNameIndex = FullTextIndex({
728751
indexName: 'LanguageEngagementName',
729752
labels: ['ProjectName', 'LanguageName', 'LanguageDisplayName'],

0 commit comments

Comments
 (0)