Skip to content

Commit

Permalink
Merge pull request #116 from Carifio24/get-class-all-data
Browse files Browse the repository at this point in the history
Rename routes for clarity
  • Loading branch information
Carifio24 authored Jun 18, 2024
2 parents b4e349a + 8843da1 commit b7859e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/stories/hubbles_law/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ async function getHubbleMeasurementsForAsyncStudent(studentID: number, classID:
return getHubbleMeasurementsForStudentClasses(studentID, classIDs);
}

export async function getStageThreeMeasurements(studentID: number, classID: number | null, lastChecked: number | null = null): Promise<HubbleMeasurement[]> {
export async function getClassMeasurements(studentID: number, classID: number | null, lastChecked: number | null = null): Promise<HubbleMeasurement[]> {
const cls = classID !== null ? await findClassById(classID) : null;
const asyncClass = cls?.asynchronous ?? true;
let data: HubbleMeasurement[] | null;
Expand Down
10 changes: 5 additions & 5 deletions src/stories/hubbles_law/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
removeHubbleMeasurement,
setGalaxySpectrumStatus,
getUncheckedSpectraGalaxies,
getStageThreeMeasurements,
getClassMeasurements,
getAllHubbleMeasurements,
getAllHubbleStudentData,
getAllHubbleClassData,
Expand Down Expand Up @@ -254,7 +254,7 @@ router.get("/sample-galaxy", async (_req, res) => {
res.json(galaxy);
});

router.get("/stage-3-data/:studentID/:classID", async (req, res) => {
router.get(["/class-measurements/:studentID/:classID", "/stage-3-data/:studentID/:classID"], async (req, res) => {
const lastCheckedStr = req.query.last_checked as string;
let lastChecked: number | null = parseInt(lastCheckedStr);
if (isNaN(lastChecked)) {
Expand Down Expand Up @@ -283,15 +283,15 @@ router.get("/stage-3-data/:studentID/:classID", async (req, res) => {
return;
}

const measurements = await getStageThreeMeasurements(studentID, classID, lastChecked);
const measurements = await getClassMeasurements(studentID, classID, lastChecked);
res.status(200).json({
studentID,
classID,
measurements
});
});

router.get("/stage-3-data/:studentID", async (req, res) => {
router.get(["/class-measurements/:studentID", "stage-3-measurements/:studentID"], async (req, res) => {
const params = req.params;
const studentID = parseInt(params.studentID);
const isValidStudent = (await findStudentById(studentID)) !== null;
Expand All @@ -302,7 +302,7 @@ router.get("/stage-3-data/:studentID", async (req, res) => {
return;
}

const measurements = await getStageThreeMeasurements(studentID, null);
const measurements = await getClassMeasurements(studentID, null);
res.status(200).json({
studentID,
measurements,
Expand Down

0 comments on commit b7859e3

Please sign in to comment.