Skip to content

Commit

Permalink
Ce 326 (#225)
Browse files Browse the repository at this point in the history
Co-authored-by: afwilcox <[email protected]>
  • Loading branch information
cnesmithsalus and afwilcox authored Dec 18, 2023
1 parent 8bd4fd1 commit 667383f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 20 deletions.
30 changes: 30 additions & 0 deletions backend/db/migrations/R__Create-Test-Data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1319,3 +1319,33 @@ UPDATE public.attractant_code SET display_order=16 WHERE attractant_code='PETFOO
UPDATE public.attractant_code SET display_order=17 WHERE attractant_code='PETS';
UPDATE public.attractant_code SET display_order=18 WHERE attractant_code='VEGGARD';
UPDATE public.attractant_code SET display_order=19 WHERE attractant_code='VNYDORCH';

-- CE-326 Adding Caribou

UPDATE species_code SET display_order = 24 where display_order = 23;
UPDATE species_code SET display_order = 23 where display_order = 22;
UPDATE species_code SET display_order = 22 where display_order = 21;
UPDATE species_code SET display_order = 21 where display_order = 20;
UPDATE species_code SET display_order = 20 where display_order = 19;
UPDATE species_code SET display_order = 19 where display_order = 18;
UPDATE species_code SET display_order = 18 where display_order = 17;
UPDATE species_code SET display_order = 17 where display_order = 16;
UPDATE species_code SET display_order = 16 where display_order = 15;
UPDATE species_code SET display_order = 15 where display_order = 14;
UPDATE species_code SET display_order = 14 where display_order = 13;
UPDATE species_code SET display_order = 13 where display_order = 12;
UPDATE species_code SET display_order = 12 where display_order = 11;
UPDATE species_code SET display_order = 11 where display_order = 10;
UPDATE species_code SET display_order = 10 where display_order = 9;
UPDATE species_code SET display_order = 9 where display_order = 8;
UPDATE species_code SET display_order = 8 where display_order = 7;
UPDATE species_code SET display_order = 7 where display_order = 6;
UPDATE species_code SET display_order = 6 where display_order = 5;
UPDATE species_code SET display_order = 5 where display_order = 4;
UPDATE species_code SET display_order = 4 where display_order = 3;
insert into species_code (species_code, short_description, long_description, display_order, active_ind, legacy_code, create_user_id, create_utc_timestamp, update_user_id, update_utc_timestamp)
values('CARIBOU', 'Caribou', 'Caribou', 3, true, null, user, now(), user, now()) ON CONFLICT DO NOTHING;

-- CE-326 Opps
UPDATE species_code SET display_order = 4 where species_code = 'CARIBOU';
UPDATE species_code SET display_order = 3 where species_code = 'BOBCAT';
43 changes: 31 additions & 12 deletions backend/src/v1/code-table/code-table.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, Logger } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Repository, SelectQueryBuilder } from "typeorm";

import BaseCodeTable, {
Agency,
Expand Down Expand Up @@ -60,7 +60,9 @@ export class CodeTableService {
getCodeTableByName = async (table: string): Promise<BaseCodeTable[]> => {
switch (table) {
case "agency": {
const data = await this._agencyRepository.find();
const data = await this._agencyRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
agency_code,
Expand All @@ -83,7 +85,9 @@ export class CodeTableService {
return results;
}
case "attractant": {
const data = await this._attractantRepository.find();
const data = await this._attractantRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
attractant_code,
Expand All @@ -105,7 +109,9 @@ export class CodeTableService {
return results;
}
case "complaint-status": {
const data = await this._complaintStatusRepository.find();
const data = await this._complaintStatusRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
complaint_status_code,
Expand All @@ -127,7 +133,9 @@ export class CodeTableService {
return results;
}
case "nature-of-complaint": {
const data = await this._natureOfComplaintRepository.find();
const data = await this._natureOfComplaintRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
hwcr_complaint_nature_code,
Expand All @@ -149,7 +157,9 @@ export class CodeTableService {
return results;
}
case "organization-unit-type": {
const data = await this._organizationUnitTypeRepository.find();
const data = await this._organizationUnitTypeRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
geo_org_unit_type_code,
Expand All @@ -171,12 +181,13 @@ export class CodeTableService {
return results;
}
case "organization-unit": {
const builder = this._organizationUnitRepository
let builder: SelectQueryBuilder<GeoOrganizationUnitCode>;
builder = this._organizationUnitRepository
.createQueryBuilder("organization_unit")
.leftJoinAndSelect(
"organization_unit.geo_org_unit_type_code",
"organization_unit_type"
);
).orderBy("organization_unit.long_description", "ASC");

const data = await builder.getMany();

Expand Down Expand Up @@ -206,7 +217,9 @@ export class CodeTableService {
return results;
}
case "person-complaint": {
const data = await this._personComplaintTypeRepository.find();
const data = await this._personComplaintTypeRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
person_complaint_xref_code,
Expand All @@ -226,7 +239,9 @@ export class CodeTableService {
return results;
}
case "species": {
const data = await this._speciesRepository.find();
const data = await this._speciesRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
species_code,
Expand All @@ -250,7 +265,9 @@ export class CodeTableService {
return results;
}
case "violation": {
const data = await this._violationsRepository.find();
const data = await this._violationsRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
violation_code,
Expand All @@ -272,7 +289,9 @@ export class CodeTableService {
return results;
}
case "complaint-type": {
const data = await this._complaintTypetRepository.find();
const data = await this._complaintTypetRepository.find(
{order: {display_order: "ASC"}}
);
let results = data.map(
({
complaint_type_code,
Expand Down
3 changes: 3 additions & 0 deletions backend/test/mocks/mock-code-table-repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export const MockOrganizationUnitTypeCodeTableRepository = () => ({
createQueryBuilder: jest.fn(() => ({
leftJoinAndSelect: jest.fn().mockReturnThis(),
where: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
getMany: jest.fn().mockResolvedValue(organizationUnitTypes),
})),
});
Expand All @@ -215,6 +216,7 @@ export const MockOrganizationUnitCodeTableRepository = () => ({
createQueryBuilder: jest.fn(() => ({
leftJoinAndSelect: jest.fn().mockReturnThis(),
where: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
getMany: jest.fn().mockResolvedValue(organizationUnits),
})),
});
Expand Down Expand Up @@ -255,6 +257,7 @@ export const MockCosOrganizationUnitCodeTableRepository = () => ({
getRawMany: jest.fn().mockReturnThis(),
leftJoinAndSelect: jest.fn().mockReturnThis(),
where: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
getMany: jest.fn().mockResolvedValue(cosOrganizationUnits),
})),
});
Expand Down
17 changes: 15 additions & 2 deletions frontend/cypress/e2e/complaint-search.v2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ describe("Complaint Search Functionality", () => {
beforeEach(function () {
cy.viewport("macbook-16");
cy.kcLogout().kcLogin();
cy.visit("/");
cy.waitForSpinner();
});

it("Can search Wildlife complaints for 'siblings '", () => {

cy.visit("/");
cy.waitForSpinner();

//-- load the human wildlife conflicts
cy.navigateToTab(complaintTypes[0], true);

Expand Down Expand Up @@ -40,6 +41,9 @@ describe("Complaint Search Functionality", () => {

it("Can search Allegations for 'Oil' and clear search when done", () => {

cy.visit("/");
cy.waitForSpinner();

//-- load the human wildlife conflicts
cy.navigateToTab(complaintTypes[1], true);

Expand All @@ -62,6 +66,9 @@ describe("Complaint Search Functionality", () => {

it("Can't search Wildlife complaints for 'Zebra'", () => {

cy.visit("/");
cy.waitForSpinner();

//-- load the human wildlife conflicts
cy.navigateToTab(complaintTypes[0], true);

Expand All @@ -86,6 +93,9 @@ describe("Complaint Search Functionality", () => {

it("Can search wildlife map complaints by complaint-id: 23-031562", () => {

cy.visit("/");
cy.waitForSpinner();

//-- load the human wildlife conflicts
cy.navigateToTab(complaintTypes[0], true);

Expand All @@ -108,6 +118,9 @@ describe("Complaint Search Functionality", () => {

it("Can search multiple allegation map complaints: ", () => {

cy.visit("/");
cy.waitForSpinner();

//-- load the human wildlife conflicts
cy.navigateToTab(complaintTypes[1], false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ export const ComplaintDetailsEdit: FC = () => {

if (from(source).any() && from(source).elementAt(0)) {
const assigned = { ...source[0], person_guid: officer, active_ind: true };
console.log("assigned1 :" + JSON.stringify(assigned));
source = [assigned];
} else {
const assigned = {
Expand All @@ -566,7 +565,6 @@ export const ComplaintDetailsEdit: FC = () => {
active_ind: true,
person_complaint_xref_code: "ASSIGNEE",
};
console.log("assigned2 :" + JSON.stringify(assigned));
source = [assigned];
}

Expand All @@ -579,7 +577,6 @@ export const ComplaintDetailsEdit: FC = () => {

} else if (from(source).any() && from(source).elementAt(0)) {
const assigned = { ...source[0], active_ind: false };
console.log("assigned3 :" + JSON.stringify(assigned));
source = [assigned];

const updatedParent = {
Expand All @@ -589,10 +586,7 @@ export const ComplaintDetailsEdit: FC = () => {

update.complaint_identifier = updatedParent;
}
console.log("updateComplaintvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv: " + JSON.stringify(update));
console.log("lol");
setUpdateComplaint(update);
console.log("lol2");
}
};

Expand Down

0 comments on commit 667383f

Please sign in to comment.