Skip to content

Commit

Permalink
finish renaming vantage to vantage_category and vantage_mode to vantage
Browse files Browse the repository at this point in the history
  • Loading branch information
mauberti-bc committed Dec 14, 2024
1 parent 493e6bd commit 4874257
Show file tree
Hide file tree
Showing 34 changed files with 817 additions and 534 deletions.
3 changes: 2 additions & 1 deletion api/src/database-models/vantage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { z } from 'zod';
* @description Data model for `vantage`.
*/
export const VantageModel = z.object({
vantage_mode_category_id: z.number(),
vantage_id: z.number(),
vantage_category_id: z.number(),
name: z.string(),
description: z.string().nullable(),
record_end_date: z.string().nullable(),
Expand Down
35 changes: 35 additions & 0 deletions api/src/database-models/vantage_category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { z } from 'zod';

/**
* Vantage category model.
*
* @description Data model for `vantage_category`.
*/
export const VantageCategoryModel = z.object({
vantage_category_id: z.number(),
name: z.string(),
description: z.string().nullable(),
record_end_date: z.string().nullable(),
create_date: z.string(),
create_user: z.number(),
update_date: z.string().nullable(),
update_user: z.number().nullable(),
revision_count: z.number()
});

export type VantageCategoryModel = z.infer<typeof VantageCategoryModel>;

/**
* Vantage Category Record.
*
* @description Data record for `vantage_category`.
*/
export const VantageCategory = VantageCategoryModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

export type VantageCategory = z.infer<typeof VantageCategory>;
36 changes: 36 additions & 0 deletions api/src/database-models/vantage_method.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { z } from 'zod';

/**
* Vantage Method Model.
*
* @description Data model for `vantage_method`.
*/
export const VantageMethodModel = z.object({
vantage_method_id: z.number(),
vantage_id: z.number(),
method_lookup_id: z.number(),
description: z.string().nullable(),
record_end_date: z.string().nullable(),
create_date: z.string(),
create_user: z.number(),
update_date: z.string().nullable(),
update_user: z.number().nullable(),
revision_count: z.number()
});

export type VantageMethodModel = z.infer<typeof VantageMethodModel>;

/**
* Vantage Method Record.
*
* @description Data record for `vantage_method`.
*/
export const VantageMethodRecord = VantageMethodModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

export type VantageMethodRecord = z.infer<typeof VantageMethodRecord>;
36 changes: 0 additions & 36 deletions api/src/database-models/vantage_mode.ts

This file was deleted.

36 changes: 0 additions & 36 deletions api/src/database-models/vantage_mode_method.ts

This file was deleted.

36 changes: 18 additions & 18 deletions api/src/openapi/schemas/technique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ export const techniqueVantagesSchema: OpenAPIV3.SchemaObject = {
description: 'Vantages from which a method is done, like water, air, or ground.',
items: {
type: 'object',
required: ['vantage_mode_method_id', 'vantage_mode_category_id'],
required: ['vantage_method_id', 'vantage_category_id'],
additionalProperties: false,
properties: {
method_technique_vantage_mode_id: {
method_technique_vantage_id: {
type: 'integer',
minimum: 1
},
vantage_mode_method_id: {
vantage_method_id: {
type: 'integer',
minimum: 1
},
vantage_mode_category_id: {
vantage_category_id: {
type: 'integer',
minimum: 1
}
Expand Down Expand Up @@ -133,7 +133,7 @@ export const techniqueCreateSchema: OpenAPIV3.SchemaObject = {
'distance_threshold',
'attractants',
'attributes',
'vantage_mode_methods'
'vantage_methods'
],
additionalProperties: false,
properties: {
Expand All @@ -158,7 +158,7 @@ export const techniqueCreateSchema: OpenAPIV3.SchemaObject = {
},
attractants: techniqueAttractantsSchema,
attributes: techniqueAttributesSchema,
vantage_mode_methods: techniqueVantagesSchema
vantage_methods: techniqueVantagesSchema
}
};

Expand Down Expand Up @@ -191,11 +191,11 @@ export const vantageReferenceRecordsSchema: OpenAPIV3.SchemaObject = {
description: 'Vantage reference records.',
items: {
type: 'object',
description: 'Vantage reference record and its associated vantage modes.',
required: ['vantage_mode_category_id', 'name', 'description', 'vantage_modes'],
description: 'Vantage category reference record and its associated vantages.',
required: ['vantage_category_id', 'name', 'description', 'vantages'],
additionalProperties: false,
properties: {
vantage_mode_category_id: {
vantage_category_id: {
type: 'integer',
minimum: 1
},
Expand All @@ -206,29 +206,29 @@ export const vantageReferenceRecordsSchema: OpenAPIV3.SchemaObject = {
type: 'string',
nullable: true
},
vantage_modes: {
vantages: {
type: 'array',
description: 'Supported vantage mode for the vantage record.',
description: 'Supported vantage for the vantage record.',
items: {
type: 'object',
required: ['vantage_mode_method_id', 'name', 'vantage_mode_category_id', 'description'],
required: ['vantage_method_id', 'name', 'vantage_id', 'description'],
additionalProperties: false,
properties: {
vantage_mode_method_id: {
vantage_method_id: {
type: 'integer',
description: 'The primary key of the vantage mode option.'
description: 'The primary key of the vantage method option.'
},
vantage_mode_category_id: {
vantage_id: {
type: 'integer',
description: 'The vantage of the mode.'
description: 'The vantage of the record'
},
name: {
type: 'string',
description: 'The name of the vantage mode option.'
description: 'The name of the vantage method option.'
},
description: {
type: 'string',
description: 'The description of the mode option.'
description: 'The description of the vantage method option.'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/paths/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ GET.apiDoc = {
},
vantages: {
type: 'array',
description: 'Vantages that vantage modes belong to.',
description: 'Vantages that vantages belong to.',
items: {
type: 'object',
additionalProperties: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ describe('createTechniques', () => {
attractant_lookup_id: 111
}
],
vantage_mode_methods: [
{ vantage_mode_method_id: 101, description: 'Mode 1' },
{ vantage_mode_method_id: 102, description: 'Mode 2' }
vantage_methods: [
{ vantage_method_id: 101, description: 'Mode 1' },
{ vantage_method_id: 102, description: 'Mode 2' }
]
}
]
Expand Down Expand Up @@ -118,9 +118,9 @@ describe('createTechniques', () => {
attractant_lookup_id: 111
}
],
vantage_mode_methods: [
{ vantage_mode_method_id: 101, description: 'Mode 1' },
{ vantage_mode_method_id: 102, description: 'Mode 2' }
vantage_methods: [
{ vantage_method_id: 101, description: 'Mode 1' },
{ vantage_method_id: 102, description: 'Mode 2' }
]
}
]
Expand Down Expand Up @@ -181,16 +181,16 @@ describe('getTechniques', () => {
}
]
},
vantage_mode_methods: [
vantage_methods: [
{
method_technique_vantage_mode_id: 1,
vantage_mode_method_id: 101,
vantage_mode_category_id: 2
method_technique_vantage_id: 1,
vantage_method_id: 101,
vantage_category_id: 2
},
{
method_technique_vantage_mode_id: 2,
vantage_mode_method_id: 102,
vantage_mode_category_id: 1
method_technique_vantage_id: 2,
vantage_method_id: 102,
vantage_category_id: 1
}
]
};
Expand Down Expand Up @@ -254,16 +254,16 @@ describe('getTechniques', () => {
}
]
},
vantage_mode_methods: [
vantage_methods: [
{
method_technique_vantage_mode_id: 1,
vantage_mode_method_id: 101,
vantage_mode_category_id: 2
method_technique_vantage_id: 1,
vantage_method_id: 101,
vantage_category_id: 2
},
{
method_technique_vantage_mode_id: 2,
vantage_mode_method_id: 102,
vantage_mode_category_id: 1
method_technique_vantage_id: 2,
vantage_method_id: 102,
vantage_category_id: 1
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ describe('updateTechnique', () => {
attractant_lookup_id: 111
}
],
vantage_mode_methods: [
{ vantage_mode_method_id: 101, description: 'Mode 1' },
{ vantage_mode_method_id: 102, description: 'Mode 2' }
vantage_methods: [
{ vantage_method_id: 101, description: 'Mode 1' },
{ vantage_method_id: 102, description: 'Mode 2' }
]
}
};
Expand Down Expand Up @@ -231,9 +231,9 @@ describe('updateTechnique', () => {
attractant_lookup_id: 111
}
],
vantage_mode_methods: [
{ vantage_mode_method_id: 101, description: 'Mode 1' },
{ vantage_mode_method_id: 102, description: 'Mode 2' }
vantage_methods: [
{ vantage_method_id: 101, description: 'Mode 1' },
{ vantage_method_id: 102, description: 'Mode 2' }
]
}
};
Expand All @@ -254,8 +254,8 @@ describe('updateTechnique', () => {
.stub(TechniqueAttributeService.prototype, 'insertUpdateDeleteQuantitativeAttributesForTechnique')
.resolves();

const updateVantageModesForTechniqueStub = sinon
.stub(TechniqueVantageService.prototype, 'updateVantageModesForTechnique')
const updateVantagesForTechniqueStub = sinon
.stub(TechniqueVantageService.prototype, 'updateVantagesForTechnique')
.resolves();

const requestHandler = updateTechnique();
Expand All @@ -280,11 +280,7 @@ describe('updateTechnique', () => {
3,
requestBody.technique.attributes.quantitative_attributes
);
expect(updateVantageModesForTechniqueStub).to.have.been.calledOnceWith(
2,
3,
requestBody.technique.vantage_mode_methods
);
expect(updateVantagesForTechniqueStub).to.have.been.calledOnceWith(2, 3, requestBody.technique.vantage_methods);

expect(mockRes.statusValue).to.eql(200);
});
Expand Down
Loading

0 comments on commit 4874257

Please sign in to comment.