Skip to content

Commit

Permalink
Add EngagementFilters.engagedName
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Aug 1, 2024
1 parent de3283a commit e07e98c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/engagement/dto/list-engagements.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export abstract class EngagementFilters {

@Field({
nullable: true,
description:
'Only engagements whose project or engaged entity (language / user) name match',
})
readonly name?: string;

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

@Field({
nullable: true,
description:
'Only engagements whose engaged entity (language / user) name match',
})
readonly engagedName?: string;

readonly languageId?: ID;
@FilterField(() => LanguageFilters)
readonly language?: LanguageFilters & {};
Expand Down
23 changes: 23 additions & 0 deletions src/components/engagement/engagement.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ export class EngagementRepository extends CommonRepository {
@OnIndex('schema')
private async createSchemaIndexes() {
await this.db.query().apply(NameIndex.create()).run();
await this.db.query().apply(EngagedNameIndex.create()).run();
await this.db.query().apply(LanguageNameIndex.create()).run();
await this.db.query().apply(InternshipNameIndex.create()).run();
}
Expand Down Expand Up @@ -553,6 +554,22 @@ export const engagementFilters = filter.define(() => EngagementFilters, {
separateQueryForEachWord: true,
minScore: 0.9,
}),
engagedName: filter.fullText({
index: () => EngagedNameIndex,
matchToNode: (q) =>
q.match([
node('node', 'Engagement'),
relation('out', '', undefined, ACTIVE),
node('', 'BaseNode'),
relation('out', '', undefined, ACTIVE),
node('match'),
]),
// Treat each word as a separate search term
// Each word could point to a different node
// i.e. "first - last"
separateQueryForEachWord: true,
minScore: 0.9,
}),
projectId: filter.pathExists((id) => [
node('node'),
relation('in', '', 'engagement'),
Expand Down Expand Up @@ -724,6 +741,12 @@ const NameIndex = FullTextIndex({
properties: 'value',
analyzer: 'standard-folding',
});
const EngagedNameIndex = FullTextIndex({
indexName: 'EngagedName',
labels: ['LanguageName', 'LanguageDisplayName', 'UserName'],
properties: 'value',
analyzer: 'standard-folding',
});
const LanguageNameIndex = FullTextIndex({
indexName: 'LanguageEngagementName',
labels: ['ProjectName', 'LanguageName', 'LanguageDisplayName'],
Expand Down

0 comments on commit e07e98c

Please sign in to comment.