Skip to content

Commit

Permalink
remaining minor issues resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
siddheshraze committed Dec 6, 2024
1 parent b1710d1 commit d737d06
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
14 changes: 14 additions & 0 deletions frontend/app/api/sqlload/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ export async function POST(request: NextRequest) {
}
}
}

// Update Census Start/End Dates
const combinedQuery = `
UPDATE ${schema}.census c
JOIN (
SELECT CensusID, MIN(MeasurementDate) AS FirstMeasurementDate, MAX(MeasurementDate) AS LastMeasurementDate
FROM ${schema}.coremeasurements
WHERE CensusID = ${censusID}
GROUP BY CensusID
) m ON c.CensusID = m.CensusID
SET c.StartDate = m.FirstMeasurementDate, c.EndDate = m.LastMeasurementDate
WHERE c.CensusID = ${censusID};`;

await connectionManager.executeQuery(combinedQuery);
await connectionManager.closeConnection();
return new NextResponse(JSON.stringify({ message: 'Insert to SQL successful', idToRows: idToRows }), { status: HTTPResponses.OK });
}
13 changes: 0 additions & 13 deletions frontend/components/processors/processcensus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,6 @@ export async function processCensus(props: Readonly<SpecialProcessingProps>): Pr
}
}

// Update Census Start/End Dates
const combinedQuery = `
UPDATE ${schema}.census c
JOIN (
SELECT CensusID, MIN(MeasurementDate) AS FirstMeasurementDate, MAX(MeasurementDate) AS LastMeasurementDate
FROM ${schema}.coremeasurements
WHERE CensusID = ${censusID}
GROUP BY CensusID
) m ON c.CensusID = m.CensusID
SET c.StartDate = m.FirstMeasurementDate, c.EndDate = m.LastMeasurementDate
WHERE c.CensusID = ${censusID};`;

await connectionManager.executeQuery(combinedQuery);
console.log('Upsert successful. CoreMeasurement ID generated:', coreMeasurementID);
return coreMeasurementID;
}
Expand Down
14 changes: 6 additions & 8 deletions frontend/components/uploadsystem/segments/uploadfireazure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,15 @@ const UploadFireAzure: React.FC<UploadFireAzureProps> = ({
};

if (!hasUploaded.current) {
uploadFiles().catch(console.error);
hasUploaded.current = true;
uploadFiles()
.catch(console.error)
.then(() => {
hasUploaded.current = true;
setReviewState(ReviewStates.COMPLETE);
});
}
}, [acceptedFiles, uploadToStorage, uploadForm, setIsDataUnsaved]);

useEffect(() => {
if (!loading && completedOperations === totalOperations && !refreshError) {
setReviewState(ReviewStates.COMPLETE);
}
}, [loading, completedOperations, totalOperations, refreshError]);

return (
<>
{loading ? (
Expand Down

0 comments on commit d737d06

Please sign in to comment.