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

chore: Fix mapSearch agency check for CEEB users #735

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
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
24 changes: 14 additions & 10 deletions backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@ export class ComplaintService {
.where("officer.user_id = :idir", { idir });

const result = await builder.getOne();

//-- pull the user's agency from the query results and return the agency code
const {
office_guid: { agency_code },
} = result;
return agency_code;
if (result.office_guid && result.office_guid.agency_code) {
afwilcox marked this conversation as resolved.
Show resolved Hide resolved
const {
office_guid: { agency_code },
} = result;
return agency_code;
} else {
return null;
}
};

private _getSortTable = (column: string): string => {
Expand Down Expand Up @@ -986,9 +989,10 @@ export class ComplaintService {
try {
let results: MapSearchResults = { complaints: [], unmappedComplaints: 0 };

//-- get the users assigned agency
const agency = await this._getAgencyByUser();

//-- assign the users agency
// _getAgencyByUser traces agency through assigned office of the officer, which CEEB users do not have
// so the hasCEEBRole is used to assign agency for them.
const agency = hasCEEBRole ? "EPO" : (await this._getAgencyByUser()).agency_code;
//-- search for complaints
let complaintBuilder = this._generateQueryBuilder(complaintType);

Expand All @@ -1005,7 +1009,7 @@ export class ComplaintService {
//-- only return complaints for the agency the user is associated with
if (agency) {
complaintBuilder.andWhere("complaint.owned_by_agency_code.agency_code = :agency", {
agency: agency.agency_code,
agency: agency,
});
}

Expand Down Expand Up @@ -1035,7 +1039,7 @@ export class ComplaintService {
//-- only return complaints for the agency the user is associated with
if (agency) {
unMappedBuilder.andWhere("complaint.owned_by_agency_code.agency_code = :agency", {
agency: agency.agency_code,
agency: agency,
});
}

Expand Down
Loading