Skip to content

Commit

Permalink
Finish PATCH update for updating eclipse data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Mar 8, 2024
1 parent 1256d7d commit 3e0a89f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/stories/solar-eclipse-2024/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const SolarEclipse2024Update = S.struct({
export type SolarEclipse2024DataT = S.Schema.To<typeof SolarEclipse2024Entry>;
export type SolarEclipse2024UpdateT = S.Schema.To<typeof SolarEclipse2024Update>;

export async function submitSolarEclipse2024Response(data: SolarEclipse2024DataT): Promise<SolarEclipse2024Data | null> {
export async function submitSolarEclipse2024Data(data: SolarEclipse2024DataT): Promise<SolarEclipse2024Data | null> {
logger.verbose(`Attempting to submit solar eclipse 2024 measurement for user ${data.user_uuid}`);

const dataWithCounts = {
Expand Down
12 changes: 10 additions & 2 deletions src/stories/solar-eclipse-2024/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { Router } from "express";
import {
getAllSolarEclipse2024Data,
getSolarEclipse2024Data,
submitSolarEclipse2024Response,
submitSolarEclipse2024Data,
SolarEclipse2024Entry,
updateSolarEclipse2024Data,
SolarEclipse2024Update,
} from "./database";

Expand All @@ -21,7 +22,7 @@ router.put("/data", async (req, res) => {
return;
}

const response = await submitSolarEclipse2024Response(maybe.right);
const response = await submitSolarEclipse2024Data(maybe.right);
if (response === null) {
res.status(400);
res.json({ error: "Error creating solar eclipse 2024 entry" });
Expand Down Expand Up @@ -58,6 +59,13 @@ router.patch("/data/:uuid", async (req, res) => {
return;
}

const success = await updateSolarEclipse2024Data(uuid, maybe.right);
if (!success) {
res.status(500).json({ error: "Error updating user data" });
return;
}
res.json({ response });

});

export default router;

0 comments on commit 3e0a89f

Please sign in to comment.