Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
siddheshraze committed Feb 3, 2025
1 parent 9fbde22 commit c7de12b
Show file tree
Hide file tree
Showing 30 changed files with 241 additions and 173 deletions.
66 changes: 33 additions & 33 deletions frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@

1. FixedData cases' queries updated to correctly work with updated schemas
2. New tables/cases added:
1. `personnelrole`
2. `sitespecificvalidations`
3. `roles`
4. `measurementssummary`
5. `viewfulltable`
1. `personnelrole`
2. `sitespecificvalidations`
3. `roles`
4. `measurementssummary`
5. `viewfulltable`

###### POST

Expand All @@ -142,18 +142,18 @@

1. Postvalidation summary statistics calculation endpoint
2. Statistics queries:
1. `number of records by quadrat`
2. `all stem records by quadrat (count only)`
3. `live stem records by quadrat (count only)`
4. `tree records by quadrat (count only)`
5. `number of dead or missing stems by census`
6. `trees outside of plot limits`
7. `stems with largest DBH/HOM measurements by species`
8. `all trees that were recorded in last census that are NOT in current census`
9. `number of new stems per quadrat per census`
10. `quadrats with most and least new stems per census`
11. `number of dead stems per quadrat per census`
12. `number of dead stems per species per census`
1. `number of records by quadrat`
2. `all stem records by quadrat (count only)`
3. `live stem records by quadrat (count only)`
4. `tree records by quadrat (count only)`
5. `number of dead or missing stems by census`
6. `trees outside of plot limits`
7. `stems with largest DBH/HOM measurements by species`
8. `all trees that were recorded in last census that are NOT in current census`
9. `number of new stems per quadrat per census`
10. `quadrats with most and least new stems per census`
11. `number of dead stems per quadrat per census`
12. `number of dead stems per species per census`

#### frontend/app/api/refreshviews/[view]/[schema]/route.ts

Expand Down Expand Up @@ -220,7 +220,7 @@
3. customized cell and edit cell rendering added
4. some exceptions exist -- for instances where specific additional handling is needed, column states are directly
defined in the datagrid components themselves.
1. `alltaxonomiesview` -- specieslimits column customized addition
1. `alltaxonomiesview` -- specieslimits column customized addition

#### GitHub Feedback Modal

Expand Down Expand Up @@ -250,18 +250,18 @@
1. The DataGridCommons generic datagrid instance has been replaced by the IsolatedDataGridCommons instance, which
isolates as much information as possible to the generic instance rather than the existing DataGridCommons, which
requires parameter drilling of all MUI X DataGrid parameters. Current datagrids using this new implementation are:
- `alltaxonomiesview`
- `attributes`
- `personnel`
- `quadratpersonnel`
- `quadrats`
- `roles`
- `stemtaxonomiesview`
- `alltaxonomiesview`
- `attributes`
- `personnel`
- `quadratpersonnel`
- `quadrats`
- `roles`
- `stemtaxonomiesview`
2. found that attempting to use typescript runtime utilities to create "default" initial states for each RDS type was
causing cascading failures. Due to the way that runtime utility functions work, no data was actually reaching the
datagrids importing those initial states
1. replaced with manual definition of initial states -- planning on centralizing this to another place, similar to
the `datagridcolumns.tsx` file
1. replaced with manual definition of initial states -- planning on centralizing this to another place, similar to
the `datagridcolumns.tsx` file
3. `measurementssummaryview` datagrid instance added as a replacement to the previously defined summary page

#### Re-Entry Data Modal
Expand Down Expand Up @@ -312,12 +312,12 @@
### SQL Updates

1. Schema has been been updated -- new tables added:
1. `roles` - outlines user roles
2. `specieslimits` - allows setting min/max bounds on measurements
3. `specimens` - recording specimen data (added on request by ForestGEO)
4. `unifiedchangelog` - partitioned table that tracks all changes to all tables in schema. All tables have triggers
that automatically update the `unifiedchangelog` on every change
5. `sitespecificvalidations` - for specific validations applicable only to the host site
1. `roles` - outlines user roles
2. `specieslimits` - allows setting min/max bounds on measurements
3. `specimens` - recording specimen data (added on request by ForestGEO)
4. `unifiedchangelog` - partitioned table that tracks all changes to all tables in schema. All tables have triggers
that automatically update the `unifiedchangelog` on every change
5. `sitespecificvalidations` - for specific validations applicable only to the host site
2. validation stored procedures have been deprecated and removed, replaced with `validationprocedures` and
`sitespecificvalidations` tables
3. migration script set has been completed and tested
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/(hub)/measurementshub/validations/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import React, { useEffect, useState, useMemo } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import useSWR from 'swr';
import { ValidationProceduresRDS } from '@/config/sqlrdsdefinitions/validations';
import { useOrgCensusContext, usePlotContext, useSiteContext } from '@/app/contexts/userselectionprovider';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/(login)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import React, { useEffect, useState } from 'react';
import { useSession } from 'next-auth/react';
import { motion, AnimatePresence } from 'framer-motion';
import { AnimatePresence, motion } from 'framer-motion';
import styles from '@/styles/styles.module.css';
import Box from '@mui/joy/Box';
import UnauthenticatedSidebar from '@/components/unauthenticatedsidebar';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/contexts/loadingprovider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React, { createContext, useContext, useEffect, useState, useRef } from 'react';
import React, { createContext, useContext, useEffect, useRef, useState } from 'react';

const LoadingContext = createContext<{
isLoading: boolean;
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/client/rendergridexplanations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { DatagridType, HeadersByDatagridType } from '@/config/macros/formdetails';
import {
AccordionGroup,
Accordion,
AccordionSummary,
AccordionDetails,
AccordionGroup,
AccordionSummary,
Alert,
Box,
Card,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { DialogTitle, IconButton, Modal, ModalDialog, Typography } from '@mui/joy';
import { DialogTitle, IconButton, Modal, ModalDialog } from '@mui/joy';
import CloseIcon from '@mui/icons-material/Close';
import MultilineSpeciesDataGrid from '@/components/datagrids/applications/multiline/multilinespeciesdatagrid';
import MultilineAttributesDataGrid from '@/components/datagrids/applications/multiline/multilineattributesdatagrid';
Expand Down
26 changes: 13 additions & 13 deletions frontend/config/connectionmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ class ConnectionManager {
return ConnectionManager.instance;
}

// Acquire a connection for the current operation
private async acquireConnectionInternal(): Promise<PoolConnection> {
try {
const connection = await getConn(); // Reuse getConn from processormacros
await connection.ping(); // Validate connection
// console.log(chalk.green('Connection validated.'));
return connection;
} catch (error) {
console.error(chalk.red('Error acquiring or validating connection:', error));
throw error;
}
}

// Execute a query using the acquired connection
public async executeQuery(query: string, params?: any[], transactionId?: string): Promise<any> {
const connection = transactionId ? this.transactionConnections.get(transactionId) : await this.acquireConnectionInternal();
Expand Down Expand Up @@ -116,6 +103,19 @@ class ConnectionManager {
public async closeConnection(): Promise<void> {
// console.warn(chalk.yellow('Warning: closeConnection is deprecated for concurrency. Connections are managed dynamically and do not persist.'));
}

// Acquire a connection for the current operation
private async acquireConnectionInternal(): Promise<PoolConnection> {
try {
const connection = await getConn(); // Reuse getConn from processormacros
await connection.ping(); // Validate connection
// console.log(chalk.green('Connection validated.'));
return connection;
} catch (error) {
console.error(chalk.red('Error acquiring or validating connection:', error));
throw error;
}
}
}

export default ConnectionManager;
4 changes: 3 additions & 1 deletion frontend/config/datagridhelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getAllTaxonomiesViewHCs, getAllViewFullTableViewsHCs, getMeasurementsSu
import { getPersonnelHCs } from '@/config/sqlrdsdefinitions/personnel';
import { getCoreMeasurementsHCs } from '@/config/sqlrdsdefinitions/core';
import { GridColDef, GridFilterModel, GridRowId, GridRowModel, GridRowModesModel, GridRowsProp, GridSortDirection } from '@mui/x-data-grid';
import { Dispatch, MutableRefObject, RefObject, SetStateAction } from 'react';
import { Dispatch, RefObject, SetStateAction } from 'react';
import { AlertProps } from '@mui/material';
import styled from '@emotion/styled';
import { getSpeciesLimitsHCs } from '@/config/sqlrdsdefinitions/taxonomies';
Expand Down Expand Up @@ -172,6 +172,7 @@ export function getGridID(gridType: string): string {
}

type VisibleFilter = 'valid' | 'errors' | 'pending';

interface ExtendedGridFilterModel extends GridFilterModel {
visible: VisibleFilter[];
}
Expand Down Expand Up @@ -243,6 +244,7 @@ export interface PendingAction {
actionType: 'save' | 'delete' | '';
actionId: GridRowId | null;
}

export const CellItemContainer = styled('div')({
display: 'flex',
flexDirection: 'column',
Expand Down
3 changes: 3 additions & 0 deletions frontend/config/macros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const booleanToBit = (value: boolean | undefined): number => (value ? 1 :

export const unitSelectionOptions = ['km', 'hm', 'dam', 'm', 'dm', 'cm', 'mm'];
export const areaSelectionOptions = ['km2', 'hm2', 'dam2', 'm2', 'dm2', 'cm2', 'mm2'];

export interface UnifiedValidityFlags {
attributes: boolean;
personnel: boolean;
Expand Down Expand Up @@ -137,6 +138,7 @@ export interface FileMapping {
columnMappings: Record<string, string>;
specialProcessing?: (props: Readonly<SpecialProcessingProps>) => Promise<void>;
}

// Define the mappings for each file type
export const fileMappings: Record<string, FileMapping> = {
attributes: {
Expand Down Expand Up @@ -192,6 +194,7 @@ export const fileMappings: Record<string, FileMapping> = {
specialProcessing: processCensus
}
};

export interface ValidationResponse {
totalRows: number;
failedRows: number;
Expand Down
1 change: 1 addition & 0 deletions frontend/config/macros/azurestorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const MAX_RETRIES = 3; // Maximum number of retries
const RETRY_DELAY_MS = 3000; // Delay between retries in milliseconds

export const FORMSEARCH_LIMIT = 5;

export interface FileRowErrors {
stemtag: string;
tag: string;
Expand Down
1 change: 1 addition & 0 deletions frontend/config/macros/siteconfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface SiteConfigProps {
icon: React.ElementType;
}[];
}

export const siteConfig = {
name: 'ForestGEO',
description: 'Census data entry and storage',
Expand Down
8 changes: 4 additions & 4 deletions frontend/config/poolmonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export class PoolMonitor {
}
}

public isPoolClosed(): boolean {
return this.poolClosed;
}

private async reinitializePool(): Promise<void> {
if (this.reinitializing) return; // Prevent concurrent reinitialization
this.reinitializing = true;
Expand Down Expand Up @@ -151,8 +155,4 @@ export class PoolMonitor {
}
}, 10000); // Poll every 10 seconds
}

public isPoolClosed(): boolean {
return this.poolClosed;
}
}
7 changes: 7 additions & 0 deletions frontend/config/sqlrdsdefinitions/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface CMAttributesRDS {
coreMeasurementID?: number;
code?: string;
}

export type CMAttributesResult = ResultType<CMAttributesRDS>;

export interface CMAttributesStagingRDS {
Expand All @@ -81,12 +82,14 @@ export interface CMAttributesStagingRDS {
}

export type CMAttributesStagingResult = ResultType<CMAttributesStagingRDS>;

export interface CMVErrorRDS {
id?: number;
cmvErrorID?: number;
coreMeasurementID?: number;
validationErrorID?: number;
}

export type CMVErrorResult = ResultType<CMVErrorRDS>;
const ATTRIBUTES_CODE_LIMIT = 10;
export const validateAttributesRow: ValidationFunction = (row: FileRow) => {
Expand All @@ -106,16 +109,19 @@ export const validateAttributesRow: ValidationFunction = (row: FileRow) => {

return Object.keys(errors).length > 0 ? errors : null;
};

export interface AttributesRDS {
id?: number;
code?: string;
description?: string;
status?: string;
}

export type AttributesResult = ResultType<AttributesRDS>;
export const initialAttributesRDSRow = createInitialObject<AttributesRDS>();
export const AttributeStatusOptions = ['alive', 'alive-not measured', 'dead', 'missing', 'broken below', 'stem dead'];
export const attributesFields = ['code', 'description', 'status'];

export interface UnifiedChangelogRDS {
id?: number;
changeID?: number;
Expand All @@ -129,4 +135,5 @@ export interface UnifiedChangelogRDS {
plotID?: number;
censusID?: number;
}

export type UnifiedChangelogResult = ResultType<UnifiedChangelogRDS>;
3 changes: 3 additions & 0 deletions frontend/config/sqlrdsdefinitions/personnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface PersonnelRDS {
lastName?: string;
roleID?: number;
}

export type PersonnelResult = ResultType<PersonnelRDS>;
// personnel table column character limits
const PERSONNEL_FIRSTNAME_LIMIT = 50;
Expand Down Expand Up @@ -47,10 +48,12 @@ export interface QuadratPersonnelRDS {
}

export type QuadratPersonnelResult = ResultType<QuadratPersonnelRDS>;

export interface RoleRDS {
id?: number;
roleID?: number;
roleName?: string;
roleDescription?: string;
}

export type RoleResult = ResultType<RoleRDS>;
Loading

0 comments on commit c7de12b

Please sign in to comment.