Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMSBIOHUB-647: Create Observations Page #1444

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b7317db
cherry-pick
mauberti-bc Dec 3, 2024
4683f3f
Tweaks
NickPhura Jan 21, 2025
a24649d
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-647b
NickPhura Jan 22, 2025
d72a7aa
Update create observation form components. Re-arrange folder structure.
NickPhura Jan 23, 2025
60f90ef
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-647b
NickPhura Jan 29, 2025
167ea81
- Updated observation components.
NickPhura Jan 29, 2025
7bbc575
Fix migration, update seeds.
NickPhura Jan 29, 2025
7daf2d3
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-647b
NickPhura Jan 29, 2025
49e7e43
Most of the backend is happy with the environment changes.
NickPhura Jan 31, 2025
676df35
Fix existing unit tests
NickPhura Jan 31, 2025
397d54b
Initial: Split some interfaces into separate files for readability
NickPhura Jan 31, 2025
a0ccafc
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-647b
NickPhura Jan 31, 2025
37747f6
Update/add database models
NickPhura Jan 31, 2025
b2586f5
Update interfaces
NickPhura Jan 31, 2025
d3c0a11
Change count back to subcount.
NickPhura Feb 1, 2025
4db6afd
Add get/find flattened observation service/repo functions
NickPhura Feb 1, 2025
bd8e33d
Remove console logs
NickPhura Feb 1, 2025
05ddb06
Fix sql
NickPhura Feb 3, 2025
24d01eb
styling subcount card
mauberti-bc Feb 3, 2025
d11c591
Merge branch 'SIMSBIOHUB-647b' of github.com:bcgov/biohubbc into SIMS…
mauberti-bc Feb 3, 2025
265fc1c
Update UI to fetch flattened observations
NickPhura Feb 3, 2025
ad03bf7
Merge branch 'SIMSBIOHUB-647b' of https://github.com/bcgov/biohubbc i…
NickPhura Feb 3, 2025
2347bea
Update observation comment column component.
NickPhura Feb 3, 2025
9073358
Fix sampling styling
NickPhura Feb 4, 2025
a4a8d03
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-647b
NickPhura Feb 4, 2025
bfa4367
Preload sites, techniques, and periods.
NickPhura Feb 4, 2025
c58073f
Fixes
NickPhura Feb 5, 2025
51dcadd
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-647b
NickPhura Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions api/src/database-models/environment_qualitative.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { z } from 'zod';

/**
* Environment Qualitative Model.
*
* @description Data model for `environment_qualitative`.
*/
export const EnvironmentQualitativeModel = z.object({
environment_qualitative_id: z.string().uuid(),
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 EnvironmentQualitativeModel = z.infer<typeof EnvironmentQualitativeModel>;

/**
* Environment Qualitative Record.
*
* @description Data record for `environment_qualitative`.
*/
export const EnvironmentQualitativeRecord = EnvironmentQualitativeModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Environment Qualitative Option Model.
*
* @description Data model for `environment_qualitative_option`.
*/
export const EnvironmentQualitativeOptionModel = z.object({
environment_qualitative_option_id: z.string(),
environment_qualitative_id: z.string(),
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 EnvironmentQualitativeOptionModel = z.infer<typeof EnvironmentQualitativeOptionModel>;

/**
* Environment Qualitative Option Record.
*
* @description Data record for `environment_qualitative_option`.
*/
export const EnvironmentQualitativeOptionRecord = EnvironmentQualitativeOptionModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Environment Quantitative Model.
*
* @description Data model for `environment_quantitative`.
*/
export const EnvironmentQuantitativeModel = z.object({
environment_quantitative_id: z.string().uuid(),
name: z.string(),
description: z.string().nullable(),
min: z.number().nullable(),
max: z.number().nullable(),
unit: EnvironmentUnit.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 EnvironmentQuantitativeModel = z.infer<typeof EnvironmentQuantitativeModel>;

/**
* Environment Quantitative Record.
*
* @description Data record for `environment_quantitative`.
*/
export const EnvironmentQuantitativeRecord = EnvironmentQuantitativeModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Observation Environment Qualitative Model.
*
* @description Data model for `observation_environment_qualitative`.
*/
export const ObservationEnvironmentQualitativeModel = z.object({
observation_environment_qualitative_id: z.number(),
survey_observation_id: z.number(),
environment_qualitative_id: z.string().uuid(),
environment_qualitative_option_id: z.string().uuid(),
create_date: z.string(),
create_user: z.number(),
update_date: z.string().nullable(),
update_user: z.number().nullable(),
revision_count: z.number()
});

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

/**
* Observation Environment Qualitative Record.
*
* @description Data record for `observation_environment_qualitative`.
*/
export const ObservationEnvironmentQualitativeRecord = ObservationEnvironmentQualitativeModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Observation Environment Quantitative Model.
*
* @description Data model for `observation_environment_quantitative`.
*/
export const ObservationEnvironmentQuantitativeModel = z.object({
observation_environment_quantitative_id: z.number(),
survey_observation_id: z.number(),
environment_quantitative_id: z.string().uuid(),
value: z.number(),
create_date: z.string(),
create_user: z.number(),
update_date: z.string().nullable(),
update_user: z.number().nullable(),
revision_count: z.number()
});

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

/**
* Observation Environment Quantitative Record.
*
* @description Data record for `observation_environment_quantitative`.
*/
export const ObservationEnvironmentQuantitativeRecord = ObservationEnvironmentQuantitativeModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Observation Sign Model.
*
* @description Data model for `observation_sign`.
*/
export const ObservationSignModel = z.object({

Check warning on line 8 in api/src/database-models/observation_sign.ts

View check run for this annotation

Codecov / codecov/patch

api/src/database-models/observation_sign.ts#L8

Added line #L8 was not covered by tests
observation_sign_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 ObservationSignModel = z.infer<typeof ObservationSignModel>;

/**
* Observation Sign Record.
*
* @description Data record for `observation_sign`.
*/
export const ObservationSignRecord = ObservationSignModel.omit({

Check warning on line 27 in api/src/database-models/observation_sign.ts

View check run for this annotation

Codecov / codecov/patch

api/src/database-models/observation_sign.ts#L27

Added line #L27 was not covered by tests
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Observation Subcount Model.
*
* @description Data model for `observation_subcount`.
*/
export const ObservationSubcountModel = z.object({
observation_subcount_id: z.number(),
survey_observation_id: z.number(),
subcount: z.number(),
comment: 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 ObservationSubcountModel = z.infer<typeof ObservationSubcountModel>;

/**
* Observation Subcount Record.
*
* @description Data record for `observation_subcount`.
*/
export const ObservationSubcountRecord = ObservationSubcountModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

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

/**
* Subcount Critter Model.
*
* @description Data model for `subcount_critter`.
*/
export const SubcountCritterModel = z.object({
subcount_critter_id: z.number(),
observation_subcount_id: z.number(),
critter_id: z.number(),
create_date: z.string(),
create_user: z.number(),
update_date: z.string().nullable(),
update_user: z.number().nullable(),
revision_count: z.number()
});

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

/**
* Subcount Critter Record.
*
* @description Data record for `subcount_critter`.
*/
export const SubcountCritterRecord = SubcountCritterModel.omit({
create_date: true,
create_user: true,
update_date: true,
update_user: true,
revision_count: true
});

export type SubcountCritterRecord = z.infer<typeof SubcountCritterRecord>;
1 change: 1 addition & 0 deletions api/src/database-models/survey_observation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const SurveyObservationModel = z.object({
count: z.number(),
observation_time: z.string().nullable(),
observation_date: z.string().nullable(),
observation_sign_id: z.number().nullable(),
create_date: z.string(),
create_user: z.number(),
update_date: z.string().nullable(),
Expand Down
23 changes: 23 additions & 0 deletions api/src/database-units/environment_unit.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do you think we should name this directory database-units or something like database-types / database-enums. I see in the database there is an additional type / enum for alert_severity would this also be a database-unit?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to any name for the folder. Can't remember how I landed on unit. Probably just trying to pick something generic that could cover database enums (but also any other enum-like concept, if there are others?), and which aren't specifically table models.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { z } from 'zod';

/**
* Environment Unit Data Type.
*
* @description Data type for `environment_unit`.
*/
export const EnvironmentUnit = z.enum([
'millimeter',
'centimeter',
'meter',
'milligram',
'gram',
'kilogram',
'percent',
'celsius',
'ppt',
'SCF',
'degrees',
'pH'
]);

export type EnvironmentUnit = z.infer<typeof EnvironmentUnit>;
9 changes: 6 additions & 3 deletions api/src/models/biohub-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ describe('PostSurveyObservationToBiohubObject', () => {
itis_tsn: 1,
itis_scientific_name: 'itis_scientific_name',
observation_time: 'observation_time',
observation_date: 'observation_date'
observation_date: 'observation_date',
observation_sign_id: 1
};

before(() => {
Expand Down Expand Up @@ -81,7 +82,8 @@ describe('PostSurveyToBiohubObject', () => {
itis_tsn: 1,
itis_scientific_name: 'itis_scientific_name',
observation_time: 'observation_time',
observation_date: 'observation_date'
observation_date: 'observation_date',
observation_sign_id: 1
};

const survey_obj: GetSurveyData = {
Expand Down Expand Up @@ -153,7 +155,8 @@ describe('PostSurveySubmissionToBioHubObject', () => {
itis_tsn: 2,
itis_scientific_name: 'itis_scientific_name',
observation_time: 'observation_time',
observation_date: 'observation_date'
observation_date: 'observation_date',
observation_sign_id: 1
}
];

Expand Down
Loading
Loading