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

Release Test to Prod #1392

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion api/.pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const phases = {
s3KeyPrefix: 'sims',
tz: config.timezone.api,
sso: config.sso.prod,
featureFlags: 'API_FF_SUBMIT_BIOHUB',
featureFlags: 'API_FF_SUBMIT_BIOHUB,API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS_CHECK',
logLevel: 'silent',
logLevelFile: 'debug',
logFileDir: 'data/logs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export function deleteDeploymentsInSurvey(): RequestHandler {

await Promise.all(deletePromises);

await connection.commit();

return res.status(200).send();
} catch (error) {
defaultLog.error({ label: 'deleteDeploymentsInSurvey', message: 'error', error });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { authorizeRequestHandler } from '../../../../../../request-handlers/secu
import { BctwDeploymentService } from '../../../../../../services/bctw-service/bctw-deployment-service';
import { ICritterbaseUser } from '../../../../../../services/critterbase-service';
import { DeploymentService } from '../../../../../../services/deployment-service';
import { isFeatureFlagPresent } from '../../../../../../utils/feature-flag-utils';
import { getLogger } from '../../../../../../utils/logger';

const defaultLog = getLogger('paths/project/{projectId}/survey/{surveyId}/deployments/index');
Expand Down Expand Up @@ -152,25 +153,27 @@ export function getDeploymentsInSurvey(): RequestHandler {
(deployment) => deployment.deployment_id === surveyDeployment.bctw_deployment_id
);

if (matchingBctwDeployments.length > 1) {
defaultLog.warn({
label: 'getDeploymentById',
message: 'Multiple active deployments found for the same deployment ID, when only one should exist.',
sims_deployment_id: surveyDeployment.deployment_id,
bctw_deployment_id: surveyDeployment.bctw_deployment_id
});

badDeployments.push({
name: 'BCTW Data Error',
message: 'Multiple active deployments found for the same deployment ID, when only one should exist.',
data: {
// TODO: If the feature flag exists, then we allow multiple active deployments to exist for the same deployment
// ID (when normally we would return a bad deployment).
if (!isFeatureFlagPresent(['API_FF_DISABLE_MULTIPLE_ACTIVE_DEPLOYMENTS_CHECK'])) {
if (matchingBctwDeployments.length > 1) {
defaultLog.warn({
label: 'getDeploymentById',
message: 'Multiple active deployments found for the same deployment ID, when only one should exist.',
sims_deployment_id: surveyDeployment.deployment_id,
bctw_deployment_id: surveyDeployment.bctw_deployment_id
}
});

// Don't continue processing this deployment
continue;
});
badDeployments.push({
name: 'BCTW Data Error',
message: 'Multiple active deployments found for the same deployment ID, when only one should exist.',
data: {
sims_deployment_id: surveyDeployment.deployment_id,
bctw_deployment_id: surveyDeployment.bctw_deployment_id
}
});
// Don't continue processing this deployment
continue;
}
}

if (matchingBctwDeployments.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class ObservationSubCountEnvironmentRepository extends BaseRepository {
surveyId: number
): Promise<QuantitativeEnvironmentTypeDefinition[]> {
const sqlStatement = SQL`
SELECT
SELECT DISTINCT
environment_quantitative.environment_quantitative_id,
environment_quantitative.name,
environment_quantitative.description,
Expand Down
2 changes: 1 addition & 1 deletion app/.pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const phases = {
maxUploadFileSize,
nodeEnv: 'production',
sso: config.sso.prod,
featureFlags: 'APP_FF_SUBMIT_BIOHUB',
featureFlags: 'APP_FF_SUBMIT_BIOHUB,APP_FF_DISABLE_BAD_DEPLOYMENT_DELETE',
cpuRequest: '50m',
cpuLimit: '1000m',
memoryRequest: '100Mi',
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ const Header: React.FC = () => {
<DialogContent>
<Typography variant="body1" component="div" color="textSecondary">
For technical support or questions about this application, please email &zwnj;
<a href="mailto:biohub@gov.bc.ca?subject=Support Request - Species Inventory Management System">
biohub@gov.bc.ca
<a href="mailto:spi_mail@gov.bc.ca?subject=Support Request - Species Inventory Management System">
spi_mail@gov.bc.ca
</a>
</Typography>
</DialogContent>
Expand Down
9 changes: 1 addition & 8 deletions app/src/components/species/components/SpeciesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ const SpeciesCard = (props: ISpeciesCardProps) => {
{commonNames}
</Typography>
</Box>
<Chip
// position="absolute"
right={5}
label={taxon.tsn}
variant="filled"
component={Box}
title="Taxonomic serial number"
/>
<Chip right={5} label={taxon.tsn} variant="filled" component={Box} title="Taxonomic serial number" />
</Stack>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SelectedAnimalSpecies = (props: ISelectedAnimalSpeciesProps) => {
{selectedSpecies.map((species, speciesIndex) => {
return (
<Collapse key={species.tsn}>
<Paper component={Stack} gap={3} variant="outlined" sx={{ p: 3, background: grey[50], my: 1 }}>
<Paper component={Stack} gap={3} variant="outlined" sx={{ px: 3, py: 2, background: grey[50], my: 1 }}>
<SpeciesSelectedCard index={speciesIndex} species={species} handleRemove={handleRemoveSpecies} />
</Paper>
</Collapse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export const AnimalListContainer = () => {
control={
<Checkbox
sx={{
mr: 1.3
mr: 0.5
}}
checked={checkboxSelectedIds.length > 0 && checkboxSelectedIds.length === crittersCount}
indeterminate={checkboxSelectedIds.length >= 1 && checkboxSelectedIds.length < crittersCount}
Expand All @@ -352,6 +352,7 @@ export const AnimalListContainer = () => {
<List>
{critters?.map((critter) => (
<CritterListItem
key={critter.critter_id}
critter={critter}
isSelectedAnimal={selectedAnimal?.critter_id === critter.critter_id}
onAnimalClick={setSelectedAnimal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const CritterListItem = (props: ICritterListItemProps) => {
<Icon path={mdiDotsVertical} size={1} />
</IconButton>
}>
<ListItemIcon>
<ListItemIcon sx={{ minWidth: 35 }}>
<Checkbox
edge="start"
checked={isCheckboxSelected}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export const FocalSpeciesForm = () => {
<TransitionGroup>
{selectedSpecies.map((species, index) => (
<Collapse key={species.tsn}>
<Paper component={Stack} gap={3} variant="outlined" sx={{ p: 3, background: grey[50], my: 1 }}>
<Paper
component={Stack}
gap={3}
variant="outlined"
sx={{ px: 3, py: 2, background: grey[50], my: 1 }}>
<SpeciesSelectedCard
species={species}
index={index}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import Paper from '@mui/material/Paper';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import { GridRowSelectionModel } from '@mui/x-data-grid';
Expand Down Expand Up @@ -160,104 +159,98 @@ const SamplingSiteContainer = () => {
</MenuItem>
</Menu>

<Paper>
<Toolbar sx={{ flex: '0 0 auto', pr: 3, pl: 2 }}>
<Typography variant="h3" component="h2" flexGrow={1}>
Sampling Sites &zwnj;
<Typography sx={{ fontWeight: '400' }} component="span" variant="inherit" color="textSecondary">
({sampleSiteCount})
</Typography>
<Toolbar sx={{ flex: '0 0 auto', pr: 3, pl: 2 }}>
<Typography variant="h3" component="h2" flexGrow={1}>
Sampling Sites &zwnj;
<Typography sx={{ fontWeight: '400' }} component="span" variant="inherit" color="textSecondary">
({sampleSiteCount})
</Typography>
<Button
variant="contained"
color="primary"
disabled={Boolean(!surveyContext.techniqueDataLoader.data?.count)}
component={RouterLink}
to={`/admin/projects/${surveyContext.projectId}/surveys/${surveyContext.surveyId}/sampling/create`}
startIcon={<Icon path={mdiPlus} size={0.8} />}>
Add
</Button>
<IconButton
edge="end"
sx={{ ml: 1 }}
aria-label="header-settings"
disabled={!siteSelection.length}
onClick={handleHeaderMenuClick}
title="Bulk Actions">
<Icon path={mdiDotsVertical} size={1} />
</IconButton>
</Toolbar>
</Typography>
<Button
variant="contained"
color="primary"
disabled={Boolean(!surveyContext.techniqueDataLoader.data?.count)}
component={RouterLink}
to={`/admin/projects/${surveyContext.projectId}/surveys/${surveyContext.surveyId}/sampling/create`}
startIcon={<Icon path={mdiPlus} size={0.8} />}>
Add
</Button>
<IconButton
edge="end"
sx={{ ml: 1 }}
aria-label="header-settings"
disabled={!siteSelection.length}
onClick={handleHeaderMenuClick}
title="Bulk Actions">
<Icon path={mdiDotsVertical} size={1} />
</IconButton>
</Toolbar>

<Divider flexItem />
<Divider flexItem />

<Box>
<LoadingGuard
isLoading={surveyContext.sampleSiteDataLoader.isLoading}
isLoadingFallback={
<>
<SkeletonMap />
<SkeletonTable numberOfLines={5} />
</>
}
isLoadingFallbackDelay={100}>
<SamplingSiteMapContainer samplingSites={sampleSites} />
<Box>
<LoadingGuard
isLoading={surveyContext.sampleSiteDataLoader.isLoading}
isLoadingFallback={
<>
<SkeletonMap />
<SkeletonTable numberOfLines={5} />
</>
}
isLoadingFallbackDelay={100}>
<SamplingSiteMapContainer samplingSites={sampleSites} />

{/* Toggle buttons for changing between sites, methods, and periods */}
<SamplingSiteTabs activeView={activeView} setActiveView={setActiveView} viewCounts={viewCounts} />
{/* Toggle buttons for changing between sites, methods, and periods */}
<SamplingSiteTabs activeView={activeView} setActiveView={setActiveView} viewCounts={viewCounts} />

<Divider flexItem />
<Divider flexItem />

{/* Data tables */}
<Box p={2}>
{activeView === SamplingSiteManageTableView.SITES && (
<LoadingGuard
isLoading={
surveyContext.sampleSiteDataLoader.isLoading || !surveyContext.sampleSiteDataLoader.isReady
}
isLoadingFallback={<SkeletonTable />}
isLoadingFallbackDelay={100}
hasNoData={!viewCounts[SamplingSiteManageTableView.SITES]}
hasNoDataFallback={
<NoDataOverlay
height="200px"
title="Add Sampling Sites"
subtitle="Apply your techniques to sampling sites to show where you collected data"
icon={mdiArrowTopRight}
/>
}
hasNoDataFallbackDelay={100}>
<SamplingSiteTable
sites={sampleSites}
setBulkActionSites={setSiteSelection}
bulkActionSites={siteSelection}
{/* Data tables */}
<Box p={2}>
{activeView === SamplingSiteManageTableView.SITES && (
<LoadingGuard
isLoading={surveyContext.sampleSiteDataLoader.isLoading || !surveyContext.sampleSiteDataLoader.isReady}
isLoadingFallback={<SkeletonTable />}
isLoadingFallbackDelay={100}
hasNoData={!viewCounts[SamplingSiteManageTableView.SITES]}
hasNoDataFallback={
<NoDataOverlay
height="200px"
title="Add Sampling Sites"
subtitle="Apply your techniques to sampling sites to show where you collected data"
icon={mdiArrowTopRight}
/>
</LoadingGuard>
)}
}
hasNoDataFallbackDelay={100}>
<SamplingSiteTable
sites={sampleSites}
setBulkActionSites={setSiteSelection}
bulkActionSites={siteSelection}
/>
</LoadingGuard>
)}

{activeView === SamplingSiteManageTableView.PERIODS && (
<LoadingGuard
isLoading={
surveyContext.sampleSiteDataLoader.isLoading || !surveyContext.sampleSiteDataLoader.isReady
}
isLoadingFallback={<SkeletonTable />}
isLoadingFallbackDelay={100}
hasNoData={!viewCounts[SamplingSiteManageTableView.PERIODS]}
hasNoDataFallback={
<NoDataOverlay
height="200px"
title="Add Periods"
subtitle="Add periods when you create sampling sites to show when you collected species observations"
icon={mdiArrowTopRight}
/>
}
hasNoDataFallbackDelay={100}>
<SamplingPeriodTable periods={samplePeriods} />
</LoadingGuard>
)}
</Box>
</LoadingGuard>
</Box>
</Paper>
{activeView === SamplingSiteManageTableView.PERIODS && (
<LoadingGuard
isLoading={surveyContext.sampleSiteDataLoader.isLoading || !surveyContext.sampleSiteDataLoader.isReady}
isLoadingFallback={<SkeletonTable />}
isLoadingFallbackDelay={100}
hasNoData={!viewCounts[SamplingSiteManageTableView.PERIODS]}
hasNoDataFallback={
<NoDataOverlay
height="200px"
title="Add Periods"
subtitle="Add periods when you create sampling sites to show when you collected species observations"
icon={mdiArrowTopRight}
/>
}
hasNoDataFallbackDelay={100}>
<SamplingPeriodTable periods={samplePeriods} />
</LoadingGuard>
)}
</Box>
</LoadingGuard>
</Box>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const CreateTechniquePage = () => {
// Parse the form data into the request format
const createTechniqueRequestData: ICreateTechniqueRequest = {
...values,
distance_threshold: values.distance_threshold || null,
attributes: {
qualitative_attributes: values.attributes
.filter(({ attribute_type }) => attribute_type === 'qualitative')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const EditTechniquePage = () => {

const formattedTechniqueObject: IUpdateTechniqueRequest = {
...values,
distance_threshold: values.distance_threshold || null,
attributes: {
quantitative_attributes: values.attributes
.filter((attribute) => attribute.attribute_type === 'quantitative')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@
flex: 0.4,
headerName: 'Method',
renderCell: (params) => (
<Box>
<ColouredRectangleChip
label={getCodesName(codesContext.codesDataLoader.data, 'sample_methods', params.row.method_lookup_id) ?? ''}
colour={blueGrey}
/>
</Box>
<ColouredRectangleChip

Check warning on line 133 in app/src/features/surveys/sampling-information/techniques/table/SamplingTechniqueTable.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/features/surveys/sampling-information/techniques/table/SamplingTechniqueTable.tsx#L133

Added line #L133 was not covered by tests
label={getCodesName(codesContext.codesDataLoader.data, 'sample_methods', params.row.method_lookup_id) ?? ''}
colour={blueGrey}
/>
)
},
{
Expand Down
Loading