Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CE-1252 Add search query for authorization id and case id #105

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/src/case_file/case_file.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export class CaseFileResolver {
return this.caseFileService.findOneByLeadId(leadIdentifier);
}

@Query("getCasesFilesBySearchString")
@Roles(Role.COS_OFFICER, Role.CEEB)
findManyBySearchString(@Args("searchString") searchString: string) {
return this.caseFileService.findManyBySearchString(searchString);
}

@Mutation("updateAssessment")
@Roles(Role.COS_OFFICER)
updateAssessment(@Args("updateAssessmentInput") updateAssessmentInput: UpdateAssessmentInput) {
Expand Down
46 changes: 46 additions & 0 deletions backend/src/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,52 @@ export class CaseFileService {
return caseFileOutput;
}

async findManyBySearchString(searchString: string) {
let caseFileOutput: Array<CaseFile> = [];

const caseIdRecords = await this.prisma.lead.findMany({
where: {
OR: [
{
case_file: {
authorization_permit: {
some: {
authorization_permit_id: {
contains: searchString,
},
active_ind: true,
},
},
},
},
{
case_file: {
site: {
some: {
site_id: {
contains: searchString,
},
active_ind: true,
},
},
},
},
],
},
select: {
lead_identifier: true,
case_identifier: true,
},
});
for (const caseIdRecord of caseIdRecords) {
caseFileOutput.push({
caseIdentifier: caseIdRecord.case_identifier,
leadIdentifier: caseIdRecord.lead_identifier,
});
}
return caseFileOutput;
}

async updateAssessment(caseIdentifier: string, updateAssessmentInput: UpdateAssessmentInput) {
let caseFileOutput: CaseFile;

Expand Down
1 change: 1 addition & 0 deletions backend/src/case_file/case_file_functions.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type Query {
getCaseFile(caseIdentifier: String!): CaseFile
getCaseFileByLeadId(leadIdentifier: String!): CaseFile
getCasesFilesBySearchString(searchString: String!): [CaseFile]
}

type Mutation {
Expand Down