Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/bcgov/biohubbc into SIMSBIOH…
Browse files Browse the repository at this point in the history
…UB-653-observations-csv
  • Loading branch information
MacQSL committed Feb 5, 2025
2 parents 41e842f + 5416b2d commit 10c702f
Show file tree
Hide file tree
Showing 70 changed files with 1,471 additions and 1,115 deletions.
24 changes: 12 additions & 12 deletions api/.pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const phases = {
logLevel: (isStaticDeployment && 'info') || 'debug',
logLevelFile: (isStaticDeployment && 'debug') || 'debug',
logFileDir: 'data/logs',
logFileName: 'sims-api-%DATE%.log',
logFileDatePattern: 'YYYY-MM-DD-HH',
logFileMaxSize: '50m',
logFileName: 'sims-api.log',
logFileDatePattern: 'YYYY-MM-DD',
logFileMaxSize: '45m',
logFileMaxFiles: (isStaticDeployment && '10') || '2',
volumeCapacity: (isStaticDeployment && '500Mi') || '100Mi',
apiResponseValidationEnabled: true,
Expand Down Expand Up @@ -138,9 +138,9 @@ const phases = {
logLevel: 'warn',
logLevelFile: 'debug',
logFileDir: 'data/logs',
logFileName: 'sims-api-%DATE%.log',
logFileDatePattern: 'YYYY-MM-DD-HH',
logFileMaxSize: '50m',
logFileName: 'sims-api.log',
logFileDatePattern: 'YYYY-MM-DD',
logFileMaxSize: '45m',
logFileMaxFiles: '10',
volumeCapacity: '500Mi',
apiResponseValidationEnabled: true,
Expand Down Expand Up @@ -182,9 +182,9 @@ const phases = {
logLevel: 'warn',
logLevelFile: 'debug',
logFileDir: 'data/logs',
logFileName: 'sims-api-%DATE%.log',
logFileDatePattern: 'YYYY-MM-DD-HH',
logFileMaxSize: '50m',
logFileName: 'sims-api.log',
logFileDatePattern: 'YYYY-MM-DD',
logFileMaxSize: '45m',
logFileMaxFiles: '10',
volumeCapacity: '500Mi',
apiResponseValidationEnabled: true,
Expand Down Expand Up @@ -226,9 +226,9 @@ const phases = {
logLevel: 'silent',
logLevelFile: 'debug',
logFileDir: 'data/logs',
logFileName: 'sims-api-%DATE%.log',
logFileDatePattern: 'YYYY-MM-DD-HH',
logFileMaxSize: '50m',
logFileName: 'sims-api.log',
logFileDatePattern: 'YYYY-MM-DD',
logFileMaxSize: '45m',
logFileMaxFiles: '10',
volumeCapacity: '500Mi',
apiResponseValidationEnabled: false,
Expand Down
11 changes: 5 additions & 6 deletions api/.pipeline/templates/api.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ parameters:
description: Api default port name
value: '6100-tcp'
# Volume (for API logs and other persistent data)
- description: Volume space available for data, e.g. 512Mi, 2Gi.
displayName: Volume Capacity
name: VOLUME_CAPACITY
- name: VOLUME_CAPACITY
required: true
description: Volume space available for data, e.g. 512Mi, 2Gi.
value: '500Mi'
# Clamav
- name: ENABLE_FILE_VIRUS_SCAN
Expand Down Expand Up @@ -149,13 +148,13 @@ parameters:
value: data/logs
description: Directory where log files are stored
- name: LOG_FILE_NAME
value: sims-api-%DATE%.log
value: sims-api.log
description: Name of the log file
- name: LOG_FILE_DATE_PATTERN
value: YYYY-MM-DD-HH
value: YYYY-MM-DD
description: Date pattern for log the files
- name: LOG_FILE_MAX_SIZE
value: 50m
value: 45m
description: Maximum size an individual log file can reach before a new file is created
- name: LOG_FILE_MAX_FILES
value: '10'
Expand Down
2 changes: 1 addition & 1 deletion api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const app: express.Express = express();

// Enable CORS
app.use(function (req: Request, res: Response, next: NextFunction) {
defaultLog.debug(`${req.method} ${req.url}`);
defaultLog.debug({ method: req.method, url: req.url });

res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Authorization, responseType');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE, HEAD');
Expand Down
2 changes: 0 additions & 2 deletions api/src/models/survey-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ export class PostPartnershipsData {

export class PostFundingSourceData {
funding_source_id: number;
amount: number;

constructor(obj?: any) {
this.funding_source_id = obj?.funding_source_id || null;
this.amount = obj?.amount ?? null;
}
}

Expand Down
2 changes: 0 additions & 2 deletions api/src/models/survey-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ export class PutSurveyParticipantsData {
export class PutFundingSourceData {
survey_funding_source_id?: number;
funding_source_id: number;
amount: number;
revision_count?: number;

constructor(obj?: any) {
this.survey_funding_source_id = obj?.survey_funding_source_id || null;
this.funding_source_id = obj?.funding_source_id || null;
this.amount = obj?.amount ?? null;
this.revision_count = obj?.revision_count || 0;
}
}
Expand Down
2 changes: 0 additions & 2 deletions api/src/models/survey-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export class GetSurveyFundingSourceData {
survey_funding_source_id: number;
survey_id: number;
funding_source_id: number;
amount: number;
revision_count?: number;
funding_source_name?: string;
start_date?: string | null;
Expand All @@ -135,7 +134,6 @@ export class GetSurveyFundingSourceData {
this.survey_funding_source_id = obj?.survey_funding_source_id || null;
this.funding_source_id = obj?.funding_source_id || null;
this.survey_id = obj?.survey_id || null;
this.amount = obj?.amount ?? null;
this.revision_count = obj?.revision_count || 0;
this.funding_source_name = obj?.funding_source_name || null;
this.start_date = obj?.start_date || null;
Expand Down
14 changes: 2 additions & 12 deletions api/src/openapi/schemas/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const surveyFundingSourceSchema: OpenAPIV3.SchemaObject = {
title: 'survey funding source response object',
type: 'object',
additionalProperties: false,
required: ['survey_funding_source_id', 'survey_id', 'funding_source_id', 'amount'],
required: ['survey_funding_source_id', 'survey_id', 'funding_source_id'],
properties: {
survey_funding_source_id: {
description: 'Survey funding source id',
Expand All @@ -101,11 +101,6 @@ export const surveyFundingSourceSchema: OpenAPIV3.SchemaObject = {
type: 'integer',
minimum: 1
},
amount: {
description: 'Funding source amount',
type: 'number',
minimum: 0
},
revision_count: {
description: 'The integer of times the record has been revised.',
type: 'integer',
Expand Down Expand Up @@ -216,7 +211,7 @@ export const surveyFundingSourceDataSchema: OpenAPIV3.SchemaObject = {
title: 'survey funding source response object',
type: 'object',
additionalProperties: false,
required: ['funding_source_id', 'amount'],
required: ['funding_source_id'],
properties: {
survey_funding_source_id: {
description: 'Survey funding source id',
Expand All @@ -234,11 +229,6 @@ export const surveyFundingSourceDataSchema: OpenAPIV3.SchemaObject = {
type: 'integer',
minimum: 1
},
amount: {
description: 'Funding source amount',
type: 'number',
minimum: 0
},
revision_count: {
description: 'The integer of times the record has been revised.',
type: 'integer',
Expand Down
5 changes: 0 additions & 5 deletions api/src/paths/funding-sources/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('getFundingSources', () => {
end_date: '2020-01-01',
description: 'description',
revision_count: 0,
survey_reference_amount_total: 2,
survey_reference_count: 20000
},
{
Expand All @@ -39,7 +38,6 @@ describe('getFundingSources', () => {
end_date: '2020-01-01',
description: 'description2',
revision_count: 0,
survey_reference_amount_total: 3,
survey_reference_count: 30000
}
];
Expand Down Expand Up @@ -90,7 +88,6 @@ describe('getFundingSources', () => {
end_date: '2020-01-01',
description: 'description',
revision_count: 0,
survey_reference_amount_total: 2,
survey_reference_count: 20000
},
{
Expand All @@ -100,7 +97,6 @@ describe('getFundingSources', () => {
end_date: '2020-01-01',
description: 'description2',
revision_count: 0,
survey_reference_amount_total: 3,
survey_reference_count: 30000
}
];
Expand Down Expand Up @@ -137,7 +133,6 @@ describe('getFundingSources', () => {
expect(mockRes.jsonValue).to.eql(
mockFundingSources.map((item) => {
// remove sensitive fields
delete item.survey_reference_amount_total;
delete item.survey_reference_count;
return item;
})
Expand Down
7 changes: 0 additions & 7 deletions api/src/paths/funding-sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ GET.apiDoc = {
minimum: 0,
description: 'The number of surveys that reference this funding source.',
nullable: true
},
survey_reference_amount_total: {
type: 'number',
minimum: 0,
description: 'The total amount from all references to this funding source by all surveys.',
nullable: true
}
}
}
Expand Down Expand Up @@ -154,7 +148,6 @@ function removeNonAdminFieldsFromFundingSourcesResponse(
): (FundingSource & FundingSourceSupplementaryData)[] {
return fundingSources.map((item) => {
delete item.survey_reference_count;
delete item.survey_reference_amount_total;
return item;
});
}
Expand Down
2 changes: 0 additions & 2 deletions api/src/paths/funding-sources/{fundingSourceId}.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ describe('getFundingSource', () => {
end_date: '2020-01-01',
description: 'description',
revision_count: 1,
survey_reference_amount_total: 100000,
survey_reference_count: 2
},
funding_source_survey_references: [
{
survey_funding_source_id: 1,
survey_id: 2,
funding_source_id: 3,
amount: 500,
revision_count: 0,
project_id: 1,
survey_name: 'survey name'
Expand Down
19 changes: 1 addition & 18 deletions api/src/paths/funding-sources/{fundingSourceId}.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ GET.apiDoc = {
funding_source: {
type: 'object',
additionalProperties: false,
required: [
'funding_source_id',
'name',
'description',
'revision_count',
'survey_reference_count',
'survey_reference_amount_total'
],
required: ['funding_source_id', 'name', 'description', 'revision_count', 'survey_reference_count'],
properties: {
funding_source_id: {
type: 'integer',
Expand All @@ -82,11 +75,6 @@ GET.apiDoc = {
minimum: 0,
description: 'The number of surveys that reference this funding source.'
},
survey_reference_amount_total: {
type: 'number',
minimum: 0,
description: 'The total amount from all references to this funding source by all surveys.'
},
start_date: {
type: 'string',
nullable: true
Expand All @@ -106,7 +94,6 @@ GET.apiDoc = {
'survey_funding_source_id',
'survey_id',
'funding_source_id',
'amount',
'revision_count',
'project_id',
'survey_name'
Expand All @@ -124,10 +111,6 @@ GET.apiDoc = {
type: 'integer',
minimum: 1
},
amount: {
type: 'number',
minimum: 0
},
revision_count: {
type: 'integer',
minimum: 0
Expand Down
14 changes: 12 additions & 2 deletions api/src/paths/project/{projectId}/survey/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PostSurveyObject } from '../../../../models/survey-create';
import {
surveyBlockSchema,
surveyDetailsSchema,
surveyFundingSourceDataSchema,
surveyLocationSchema,
surveyPartnershipsSchema,
surveyPermitSchema,
Expand Down Expand Up @@ -94,7 +93,18 @@ POST.apiDoc = {
permit: surveyPermitSchema,
funding_sources: {
type: 'array',
items: surveyFundingSourceDataSchema
items: {
type: 'object',
additionalProperties: false,
required: ['funding_source_id'],
properties: {
funding_source_id: {
description: 'Funding source id',
type: 'integer',
minimum: 1
}
}
}
},
partnerships: surveyPartnershipsSchema,
proprietor: surveyProprietorSchema,
Expand Down
25 changes: 23 additions & 2 deletions api/src/paths/project/{projectId}/survey/{surveyId}/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PutSurveyObject } from '../../../../../models/survey-update';
import {
surveyBlockSchema,
surveyDetailsSchema,
surveyFundingSourceDataSchema,
surveyLocationSchema,
surveyPartnershipsSchema,
surveyPermitSchema,
Expand Down Expand Up @@ -84,7 +83,29 @@ PUT.apiDoc = {
permit: surveyPermitSchema,
funding_sources: {
type: 'array',
items: surveyFundingSourceDataSchema
items: {
type: 'object',
additionalProperties: false,
required: ['funding_source_id'],
properties: {
survey_funding_source_id: {
description: 'Survey funding source primary id',
type: 'integer',
minimum: 1,
nullable: true
},
funding_source_id: {
description: 'Funding source reference id',
type: 'integer',
minimum: 1
},
revision_count: {
description: 'The integer of times the record has been revised.',
type: 'integer',
minimum: 0
}
}
}
},
partnerships: surveyPartnershipsSchema,
proprietor: {
Expand Down
19 changes: 17 additions & 2 deletions api/src/paths/user/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ describe('users', () => {

sinon.stub(db, 'getDBConnection').returns(mockDBConnection);

const mockResponse = [
const mockTotal = 10;
const mockPaginationParams = {
total: mockTotal,
per_page: 10,
current_page: 1,
last_page: 1,
sort: undefined,
order: undefined
};
const mockUsers = [
{
system_user_id: 1,
user_identifier: 'testname',
Expand All @@ -39,7 +48,13 @@ describe('users', () => {
}
];

sinon.stub(UserService.prototype, 'listSystemUsers').resolves(mockResponse);
const mockResponse = {
users: mockUsers,
pagination: mockPaginationParams
};

sinon.stub(UserService.prototype, 'listSystemUsers').resolves(mockUsers);
sinon.stub(UserService.prototype, 'getSystemUsersCount').resolves(mockTotal);

const requestHandler = users.getUserList();

Expand Down
Loading

0 comments on commit 10c702f

Please sign in to comment.