Skip to content

Commit

Permalink
Merge branch 'main' into PIMS-1859-PID-Formatter-Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarkowsky authored Sep 9, 2024
2 parents a3396b9 + 92aa205 commit 3746678
Show file tree
Hide file tree
Showing 20 changed files with 192 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.

* @LawrenceLau2020 @Sharala-Perumal @dbarkowsky @TaylorFries @GrahamS-Quartech @ManishSihag
* @LawrenceLau2020 @Sharala-Perumal @dbarkowsky @TaylorFries @ManishSihag

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Example: PIMS-700: A great ticket
## 🎯 Summary

<!-- EDIT JIRA LINK BELOW -->
[PIMS-###: ](https://apps.itsm.gov.bc.ca/jira/browse/PIMS-###)
[PIMS-####](https://citz-imb.atlassian.net/browse/PIMS-####)

<!-- PROVIDE BELOW an explanation of your changes -->

Expand Down
32 changes: 0 additions & 32 deletions express-api/.eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions express-api/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-undef */
module.exports = {
semi: true,
trailingComma: 'all',
Expand Down
36 changes: 36 additions & 0 deletions express-api/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import prettierPlugin from 'eslint-plugin-prettier';
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
// Specify the parser for TypeScript
languageOptions: {
parser: tseslint.parser,
},
plugins: {
prettier: prettierPlugin,
},
// Define your ESLint rules
rules: {
'prettier/prettier': 'warn',
'no-extra-boolean-cast': 'off',
'no-unsafe-optional-chaining': 'off',
'no-prototype-builtins': 'off',
'no-console': 'error', // Use logger instead
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'error',
},
// Include these files in linting
files: ['**/*.ts', '**/*.js'],
},
{
// Ignore specific files and directories. node_modules ignored by default
ignores: ['package-lock.json', 'dist/', 'coverage/'],
},
);
12 changes: 6 additions & 6 deletions express-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "nodemon --exec ts-node -r tsconfig-paths/register -r dotenv/config ./src/server.ts dotenv_config_path=../.env",
"build": "tsc && tsc-alias",
"lint": "eslint './' --ext .ts,.js",
"lint": "eslint",
"lint:fix": "npm run lint -- --fix",
"format": "prettier --write \"./**/*.{js,ts,json}\"",
"check": "prettier --check \"./**/*.{js,ts,json}\"",
Expand Down Expand Up @@ -46,6 +46,7 @@
"zod": "3.23.3"
},
"devDependencies": {
"@eslint/js": "9.9.1",
"@faker-js/faker": "8.4.0",
"@types/compression": "1.7.4",
"@types/cookie-parser": "1.4.5",
Expand All @@ -54,16 +55,14 @@
"@types/jest": "29.5.10",
"@types/morgan": "1.9.9",
"@types/multer": "1.4.11",
"@types/node": "22.3.0",
"@types/node": "22.5.0",
"@types/node-cron": "3.0.11",
"@types/nunjucks": "3.2.6",
"@types/supertest": "6.0.2",
"@types/swagger-jsdoc": "6.0.4",
"@types/swagger-ui-express": "4.1.6",
"@typescript-eslint/eslint-plugin": "8.1.0",
"@typescript-eslint/parser": "8.1.0",
"cross-env": "7.0.3",
"eslint": "8.57.0",
"eslint": "9.9.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"jest": "29.7.0",
Expand All @@ -72,6 +71,7 @@
"supertest": "7.0.0",
"ts-jest": "29.2.0",
"tsc-alias": "1.8.8",
"typescript": "5.5.2"
"typescript": "5.5.2",
"typescript-eslint": "8.3.0"
}
}
68 changes: 44 additions & 24 deletions express-api/src/services/properties/propertiesServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,41 @@ const makeParcelUpsertObject = async (
currRowEvaluations.push(...evaluations);
currRowFiscals.push(...fiscals);
}
if (row.Netbook && !currRowFiscals.some((a) => a.FiscalYear == row.FiscalYear)) {
currRowFiscals.push({
// if there is a netbook and fiscal year we can add or update fiscal
if (row.Netbook && row.FiscalYear) {
const addOrUpdateFiscals: Partial<ParcelFiscal> = {
Value: row.Netbook,
FiscalKeyId: 0,
FiscalYear: row.FiscalYear,
CreatedById: user.Id,
CreatedOn: new Date(),
});
};
if (!currRowFiscals.some((a) => a.FiscalYear == row.FiscalYear)) {
addOrUpdateFiscals.CreatedById = user.Id;
} else {
addOrUpdateFiscals.UpdatedById = user.Id;
}
currRowFiscals.push(addOrUpdateFiscals);
}
if (row.Assessed && !currRowEvaluations.some((a) => a.Year == row.EvaluationYear)) {
currRowEvaluations.push({
// if there is a netbook and fiscal year we can add or update evaluation
if (row.Assessed && row.AssessedYear) {
const addOrUpdateAssessed: Partial<ParcelEvaluation> = {
Value: row.Assessed,
EvaluationKeyId: 0,
Year: row.AssessedYear,
CreatedById: user.Id,
CreatedOn: new Date(),
});
};
if (!currRowEvaluations.some((a) => a.Year == row.AssessedYear)) {
addOrUpdateAssessed.CreatedById = user.Id;
} else {
addOrUpdateAssessed.UpdatedById = user.Id;
}
currRowEvaluations.push(addOrUpdateAssessed);
}

const classificationId: number = getClassificationOrThrow(row, lookups.classifications);
const adminAreaId: number = getAdministrativeAreaOrThrow(row, lookups.adminAreas);
const pin = numberOrNull(row.PIN) ?? existentParcel?.PIN;
const description = row.Description ?? (existentParcel ? existentParcel.Description : '');
const description = row.Description ?? existentParcel?.Description;
const isSensitive = setNewBool(row.IsSensitive, existentParcel?.IsSensitive, false);
const landArea = numberOrNull(row.LandArea) ?? existentParcel?.LandArea;

return {
Id: existentParcel?.Id,
Expand All @@ -433,7 +445,7 @@ const makeParcelUpsertObject = async (
IsSensitive: isSensitive,
PropertyTypeId: 0,
Description: description,
LandArea: numberOrNull(row.LandArea) ?? existentParcel ? existentParcel.LandArea : null,
LandArea: landArea,
Evaluations: currRowEvaluations,
Fiscals: currRowFiscals,
};
Expand Down Expand Up @@ -469,24 +481,33 @@ const makeBuildingUpsertObject = async (
currRowEvaluations.push(...evaluations);
currRowFiscals.push(...fiscals);
}

if (row.Netbook && !currRowFiscals.some((a) => a.FiscalYear == row.FiscalYear)) {
currRowFiscals.push({
// if there is a netbook and fiscal year we can add or update fiscal
if (row.Netbook && row.FiscalYear) {
const addOrUpdateFiscals: Partial<BuildingFiscal> = {
Value: row.Netbook,
FiscalKeyId: 0,
FiscalYear: row.FiscalYear,
CreatedById: user.Id,
CreatedOn: new Date(),
});
};
if (!currRowFiscals.some((a) => a.FiscalYear == row.FiscalYear)) {
addOrUpdateFiscals.CreatedById = user.Id;
} else {
addOrUpdateFiscals.UpdatedById = user.Id;
}
currRowFiscals.push(addOrUpdateFiscals);
}
if (row.Assessed && !currRowEvaluations.some((a) => a.Year == row.EvaluationYear)) {
currRowEvaluations.push({
// if there is a netbook and fiscal year we can add or update evaluation
if (row.Assessed && row.AssessedYear) {
const addOrUpdateAssessed: Partial<BuildingEvaluation> = {
Value: row.Assessed,
EvaluationKeyId: 0,
Year: row.AssessedYear,
CreatedById: user.Id,
CreatedOn: new Date(),
});
};
if (!currRowEvaluations.some((a) => a.Year == row.AssessedYear)) {
addOrUpdateAssessed.CreatedById = user.Id;
} else {
addOrUpdateAssessed.UpdatedById = user.Id;
}
currRowEvaluations.push(addOrUpdateAssessed);
}

const classificationId = getClassificationOrThrow(row, lookups.classifications);
Expand Down Expand Up @@ -805,7 +826,6 @@ const getPropertiesUnion = async (filter: PropertyUnionFilter) => {

// Add quickfilter part
if (filter.quickFilter) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const quickFilterOptions: FindOptionsWhere<any>[] = [];
const quickfilterFields = [
'Agency',
Expand Down
5 changes: 4 additions & 1 deletion express-api/src/utilities/helperFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const constructFindOptionFromQueryPid = <T>(
): FindOptionsWhere<T> => {
if (operatorValuePair == null || operatorValuePair.match(/([^,]*),(.*)/) == null)
return { [column]: undefined } as FindOptionsWhere<T>;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, operator, value] = operatorValuePair.match(/([^,]*),(.*)/).map((a) => a.trim());
const trimmedValue = value.replace(/[-]/g, ''); //remove all hyphens;
Expand Down Expand Up @@ -49,6 +50,7 @@ export const constructFindOptionFromQueryBoolean = <T>(
): FindOptionsWhere<T> => {
if (operatorValuePair == null || operatorValuePair.match(/([^,]*),(.*)/) == null)
return { [column]: undefined } as FindOptionsWhere<T>;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, operator, value] = operatorValuePair.match(/([^,]*),(.*)/).map((a) => a.trim());
let internalMatcher;
Expand Down Expand Up @@ -106,6 +108,7 @@ export const constructFindOptionFromQuery = <T>(
): FindOptionsWhere<T> => {
if (operatorValuePair == null || operatorValuePair.match(/([^,]*),(.*)/) == null)
return { [column]: undefined } as FindOptionsWhere<T>;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, operator, value] = operatorValuePair.match(/([^,]*),(.*)/).map((a) => a.trim());
let internalMatcher;
Expand Down Expand Up @@ -207,7 +210,7 @@ export const IsAnyOfWrapper = (elements: string[]) => {
//ie. It will pass Project.ProjectNumber instead of "Project_project_number" (correct column alias constructed by TypeORM)
//or "Project".project_number (correct table alias plus non-aliased column access)
//Thankfully, it's not too difficult to manually format this.
// eslint-disable-next-line @typescript-eslint/no-unused-vars

export const fixColumnAlias = (str: string) => {
const [tableAlias, columnAlias] = str.split('.');
const fixedColumn = columnAlias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ const _getUser = jest
.mockImplementation((guid: string) => ({ ...produceUser(), KeycloakUserId: guid }));
const _getAgencies = jest.fn().mockImplementation(async () => [1, 2, 3]);
const _getProjectNotificationsInQueue = jest.fn().mockImplementation(async () => [1, 2, 3]);
const _getProjectById = jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async (_id: number) => ({ AgencyId: 1 }),
);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _getProjectById = jest.fn().mockImplementation(async (_id: number) => ({ AgencyId: 1 }));
const _getNotifById = jest
.fn()
.mockImplementation((id: number) => produceNotificationQueue({ Id: id }));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Request, Response } from 'express';
import controllers from '@/controllers';
import {
Expand All @@ -10,7 +9,6 @@ import {
} from '../../../testUtils/factories';
import { faker } from '@faker-js/faker';
import { SSOIdirUser, SSOUser } from '@bcgov/citz-imb-sso-express';
import { ErrorWithCode } from '@/utilities/customErrors/ErrorWithCode';
import { Roles } from '@/constants/roles';
import { UUID } from 'crypto';

Expand All @@ -26,7 +24,7 @@ const _addKeycloakUserOnHold = jest
Position: position,
Note: note,
}));
const _updateAccessRequest = jest.fn().mockImplementation((req) => req);
jest.fn().mockImplementation((req) => req);
const _getAgencies = jest.fn().mockImplementation(() => ['1', '2', '3']);
const _getAdministrators = jest.fn();
const _getUser = jest
Expand Down
1 change: 0 additions & 1 deletion express-api/tests/unit/services/ches/chesServices.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-var */
import chesServices, { IEmail } from '@/services/ches/chesServices';
import { randomUUID } from 'crypto';
import { produceEmail, produceSSO } from 'tests/testUtils/factories';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import geocoderService from '@/services/geocoder/geocoderService';

const mockJson = {
Expand Down Expand Up @@ -109,7 +108,7 @@ describe('UNIT - Geoserver services', () => {
const stringPids = JSON.stringify(pidData);

it('should get a list of PIDs connected to the site address.', async () => {
const fetchMock = jest
jest
.spyOn(global, 'fetch')
.mockImplementationOnce(() => Promise.resolve(new Response(stringPids)));
const pids = await geocoderService.getPids('eccd759a-8476-46b0-af5d-e1c071f8e78e');
Expand All @@ -118,7 +117,7 @@ describe('UNIT - Geoserver services', () => {
});

it('should thow an error if geocoder service is down.', async () => {
const fetchMock = jest
jest
.spyOn(global, 'fetch')
.mockImplementationOnce(() => Promise.resolve(new Response('', { status: 500 })));
expect(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ const _mockEntityManager = {
},
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _queryRunner = jest.spyOn(AppDataSource, 'createQueryRunner').mockReturnValue({
jest.spyOn(AppDataSource, 'createQueryRunner').mockReturnValue({
...jest.requireActual('@/appDataSource').createQueryRunner,
startTransaction: _mockStartTransaction,
rollbackTransaction: _mockRollbackTransaction,
Expand Down
Loading

0 comments on commit 3746678

Please sign in to comment.