Skip to content

Commit

Permalink
Merge branch 'release/0.6.9' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilcox authored Dec 11, 2024
2 parents 69930d9 + ed8d130 commit 7b94334
Show file tree
Hide file tree
Showing 37 changed files with 1,194 additions and 1,227 deletions.
841 changes: 290 additions & 551 deletions backend/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"date-fns-tz": "^3.1.3",
"dotenv": "^16.0.1",
"escape-html": "^1.0.3",
"fix-esm": "^1.0.1",
"form-data": "^4.0.0",
"geojson": "^0.5.0",
"jest-mock": "^29.6.1",
Expand All @@ -82,6 +83,7 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^4.0.0",
"rxjs": "^7.8.0",
"supercluster": "^7.1.5",
"swagger-ui-express": "^4.6.0",
"typeorm": "^0.3.14",
"winston": "^3.9.0"
Expand All @@ -92,6 +94,7 @@
"@types/jest": "^29.5.1",
"@types/node": "^18.11.18",
"@types/passport-jwt": "^3.0.8",
"@types/supercluster": "^7.1.3",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ export interface ComplaintSearchParameters
PageParameters,
ComplaintFilterParameters,
SearchParameters {}

export interface ComplaintMapSearchClusteredParameters extends ComplaintSearchParameters {
bbox: string;
zoom: number;
clusters: boolean;
unmapped: boolean;
}
12 changes: 6 additions & 6 deletions backend/src/types/models/complaints/map-search-results.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { WildlifeComplaintDto } from "./wildlife-complaint";
import { AllegationComplaintDto } from "./allegation-complaint";
import { GeneralIncidentComplaintDto } from "./gir-complaint";

export interface MapSearchResults {
complaints: WildlifeComplaintDto[] | AllegationComplaintDto[] | GeneralIncidentComplaintDto[];
unmappedComplaints: number;
clusters?: any;
mappedCount?: number;
unmappedCount?: number;
zoom?: number;
center?: Array<number>;
debugLog?: string;
}
2 changes: 1 addition & 1 deletion backend/src/v1/code-table/code-table.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from "@nestjs/testing";
import { getRepositoryToken } from "@nestjs/typeorm";
import { INestApplication } from "@nestjs/common";
import * as request from "supertest";
import request from "supertest";

import { authGuardMock } from "../../../test/mocks/authGuardMock";
import { roleGuardMock } from "../../../test/mocks/roleGuardMock";
Expand Down
20 changes: 18 additions & 2 deletions backend/src/v1/complaint/complaint.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { COMPLAINT_TYPE } from "../../types/models/complaints/complaint-type";
import { WildlifeComplaintDto } from "../../types/models/complaints/wildlife-complaint";
import { AllegationComplaintDto } from "../../types/models/complaints/allegation-complaint";
import { ComplaintDto } from "../../types/models/complaints/complaint";
import { ComplaintSearchParameters } from "../../types/models/complaints/complaint-search-parameters";
import {
ComplaintSearchParameters,
ComplaintMapSearchClusteredParameters,
} from "../../types/models/complaints/complaint-search-parameters";
import { ZoneAtAGlanceStats } from "src/types/zone_at_a_glance/zone_at_a_glance_stats";
import { GeneralIncidentComplaintDto } from "src/types/models/complaints/gir-complaint";
import { ApiKeyGuard } from "src/auth/apikey.guard";
Expand Down Expand Up @@ -45,7 +48,7 @@ export class ComplaintController {
return await this.service.findAllByType(complaintType);
}

@Get("/map/search/:complaintType")
/* @Get("/map/search/:complaintType")
@Roles(Role.COS_OFFICER, Role.CEEB)
mapSearch(
@Param("complaintType") complaintType: COMPLAINT_TYPE,
Expand All @@ -56,6 +59,19 @@ export class ComplaintController {
const hasCEEBRole = hasRole(req, Role.CEEB);
return this.service.mapSearch(complaintType, model, hasCEEBRole, token);
} */

@Get("/map/search/clustered/:complaintType")
@Roles(Role.COS_OFFICER, Role.CEEB)
mapSearchClustered(
@Param("complaintType") complaintType: COMPLAINT_TYPE,
@Query() model: ComplaintMapSearchClusteredParameters,
@Request() req,
@Token() token,
) {
const hasCEEBRole = hasRole(req, Role.CEEB);

return this.service.mapSearchClustered(complaintType, model, hasCEEBRole, token);
}

@Get("/search/:complaintType")
Expand Down
49 changes: 30 additions & 19 deletions backend/src/v1/complaint/complaint.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ import {
MockUpdateComplaintsRepository,
} from "../../../test/mocks/mock-complaints-repositories";
import { dataSourceMockFactory } from "../../../test/mocks/datasource";
import { ComplaintSearchParameters } from "../../types/models/complaints/complaint-search-parameters";
import {
ComplaintSearchParameters,
ComplaintMapSearchClusteredParameters,
} from "../../types/models/complaints/complaint-search-parameters";
import { GirTypeCode } from "../gir_type_code/entities/gir_type_code.entity";
import { GirComplaint } from "../gir_complaint/entities/gir_complaint.entity";
import { ComplaintUpdatesService } from "../complaint_updates/complaint_updates.service";
Expand Down Expand Up @@ -316,51 +319,59 @@ describe("Testing: Complaint Service", () => {
it("should return list of complaints by mapSearch for non ceeb role users", async () => {
//-- arrange
const _complaintType: COMPLAINT_TYPE = "HWCR";
const payload: ComplaintSearchParameters = {
sortBy: "incident_reported_utc_timestmp",
orderBy: "DESC",
const payload: ComplaintMapSearchClusteredParameters = {
zone: "CRBOTMPSN",
status: "OPEN",
page: 1,
pageSize: 50,
query: "bear",
zoom: 17,
clusters: true,
unmapped: true,
bbox: undefined,
page: undefined,
pageSize: undefined,
sortBy: undefined,
orderBy: undefined,
};

//-- act
const results = await service.mapSearch(_complaintType, payload, false);
const results = await service.mapSearchClustered(_complaintType, payload, false);

//-- assert
expect(results).not.toBe(null);

const { unmappedComplaints, complaints } = results;
const { mappedCount, unmappedCount } = results;

expect(complaints.length).toBe(5);
expect(unmappedComplaints).toBe(55);
expect(mappedCount).toBe(5);
expect(unmappedCount).toBe(55);
});

it("should return list of complaints by mapSearch for user with ceeb role", async () => {
//-- arrange
const _complaintType: COMPLAINT_TYPE = "HWCR";
const payload: ComplaintSearchParameters = {
sortBy: "incident_reported_utc_timestmp",
orderBy: "DESC",
const payload: ComplaintMapSearchClusteredParameters = {
zone: "CRBOTMPSN",
status: "OPEN",
page: 1,
pageSize: 50,
query: "bear",
zoom: 17,
clusters: true,
unmapped: true,
bbox: undefined,
page: undefined,
pageSize: undefined,
sortBy: undefined,
orderBy: undefined,
};

//-- act
const results = await service.mapSearch(_complaintType, payload, true);
const results = await service.mapSearchClustered(_complaintType, payload, true);

//-- assert
expect(results).not.toBe(null);

const { unmappedComplaints, complaints } = results;
const { mappedCount, unmappedCount } = results;

expect(complaints.length).toBe(5);
expect(unmappedComplaints).toBe(55);
expect(mappedCount).toBe(5);
expect(unmappedCount).toBe(55);
});
});

Expand Down
Loading

0 comments on commit 7b94334

Please sign in to comment.