-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
viewfulltable bug -- no data being returned. reworked backend SQL con…
…dition and verified function on local dev server. Added missing handling for quadrat form file processing -- forgot to add censusquadrat handling to that API
- Loading branch information
1 parent
5439c4f
commit 9566975
Showing
7 changed files
with
79 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { SpecialProcessingProps } from '@/components/processors/processormacros'; | ||
import { createError, handleUpsert } from '@/config/utils'; | ||
import { CensusQuadratResult, QuadratResult } from '@/config/sqlrdsdefinitions/zones'; | ||
|
||
export async function processQuadrats(props: Readonly<SpecialProcessingProps>) { | ||
const { connection, rowData, schema, censusID } = props; | ||
if (!censusID) throw createError('CensusID missing', { censusID }); | ||
|
||
const { quadrat, startx, starty, coordinateunit, dimx, dimy, dimensionunit, area, areaunit, quadratshape } = rowData; | ||
|
||
try { | ||
await connection.beginTransaction(); | ||
const quadratsData = { | ||
QuadratName: quadrat, | ||
StartX: startx, | ||
StartY: starty, | ||
CoordinateUnit: coordinateunit, | ||
DimensionX: dimx, | ||
DimensionY: dimy, | ||
DimensionUnit: dimensionunit, | ||
Area: area, | ||
AreaUnit: areaunit, | ||
QuadratShape: quadratshape | ||
}; | ||
|
||
const quadratID = await handleUpsert<QuadratResult>(connection, schema, 'quadrats', quadratsData, 'QuadratID'); | ||
if (!quadratID) throw createError('upsert failure for row: ', { quadratsData }); | ||
|
||
// need to update censusquadrat | ||
|
||
const cqData = { | ||
CensusID: censusID, | ||
QuadratID: quadratID | ||
}; | ||
const cqID = await handleUpsert<CensusQuadratResult>(connection, schema, 'censusquadrat', cqData, 'CQID'); | ||
if (!cqID) throw createError('upsert failure on censusquadrat for row: ', { cqData }); | ||
|
||
await connection.commit(); | ||
return quadratID; | ||
} catch (error: any) { | ||
await connection.rollback(); | ||
console.error('Upsert failed:', error.message); | ||
throw createError('Upsert failed', { error }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters