Skip to content

Commit

Permalink
πŸ¦‡πŸ² ↝ [SSM-109 SSC-75 SSC-79 SSM-88]: Planet Hunters temperature mission
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Feb 8, 2025
1 parent 212de34 commit 9d2f935
Show file tree
Hide file tree
Showing 10 changed files with 547 additions and 153 deletions.
5 changes: 2 additions & 3 deletions app/tests/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"use client";

import { BasicPopupModal } from "@/components/Layout/Modal";
import { useSession } from "@supabase/auth-helpers-react";
import PlanetTempCalculator from "@/components/Structures/Missions/Astronomers/PlanetHunters/TemperatureCalc";

export default function TestPage() {
const session = useSession();

return (
// <StarnetLayout>
<>
<BasicPopupModal />
<p>{session?.user.id}</p>
<PlanetTempCalculator />
</>
// {/* </StarnetLayout> */}
);
Expand Down
2 changes: 1 addition & 1 deletion components/Projects/(classifications)/FreeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const FreeformUploadData = () => {
setButtonPressed(true);
setTimeout(() => {
setButtonPressed(false);
setLoadingContent(true);
setLoadingContent(true);
}, 200);

const imageSrc = webcamRef.current?.getScreenshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FirstTelescopeClassification, StarterTelescopeTess } from "@/components
import VotePlanetClassifictions from "./PHVote";
import PHClassificationGenerator from "./PlanetMaker";
import PlanetTemperatureForm from "./PlanetTemperature";
import PlanetHuntersTemperatureWrapper from "./PlanetTemperature";

interface MissionStep {
id: number;
Expand Down Expand Up @@ -48,42 +49,42 @@ const PlanetHuntersSteps = () => {
.select("*")
.eq("classificationtype", "planet")
.eq("author", session.user.id);

if (classificationsError) throw classificationsError;

const mission1CompletedCount = classificationsData?.length || 0;

const mission2Data =
classificationsData?.filter((classification) => {
const config = classification.classificationConfiguration;
if (!config) return false;

const options = config.classificationOptions?.[""] || {};
return (
!options["1"] &&
(options["2"] || options["3"] || options["4"])
);
}) || [];
const mission2CompletedCount = mission2Data.length;

const { data: commentsData, error: commentsError } = await supabase
.from("comments")
.select("*")
.eq("author", session.user.id);

if (commentsError) throw commentsError;

const mission3CompletedCount = commentsData?.filter(
(comment) => comment.configuration?.planetType
).length || 0;

const { data: votesData, error: votesError } = await supabase
.from("votes")
.select("*")
.eq("user_id", session.user.id);

if (votesError) throw votesError;

const planetVotes = votesData?.filter((vote) =>
classificationsData?.some(
(classification) =>
Expand All @@ -92,29 +93,24 @@ const PlanetHuntersSteps = () => {
)
) || [];
const mission4CompletedCount = planetVotes.length;

const mission5CompletedCount = commentsData?.filter(
(comment) =>
comment.classification_id &&
classificationsData?.some(
(classification) =>
classification.id === comment.classification_id &&
classification.classificationtype === "planet"
)
comment.configuration?.temperature
).length || 0;

const totalPoints = (
mission1CompletedCount * missionPoints[1] +
mission2CompletedCount * missionPoints[2] +
mission3CompletedCount * missionPoints[3] +
mission4CompletedCount * missionPoints[4] +
mission5CompletedCount * missionPoints[5]
);

const newLevel = Math.floor(totalPoints / 9) + 1;
setLevel(newLevel);
setExperiencePoints(totalPoints);

setSteps([
{
id: 1,
Expand Down Expand Up @@ -161,11 +157,10 @@ const PlanetHuntersSteps = () => {
title: "Calculate planetary temperatures",
description: "Use satellite data to help determine the temperature of planets you've discovered",
action: () => {},
// completedCount: mission4CompletedCount
color: 'text-yellow-700',
chapter: 1,
chapter: 2,
icon: "symbol",
completedCount: 0
completedCount: mission5CompletedCount,
},
{
id: 6,
Expand All @@ -178,13 +173,13 @@ const PlanetHuntersSteps = () => {
chapter: 2,
},
]);

setLoading(false);
} catch (error) {
console.error("Error fetching mission data:", error);
setLoading(false);
}
};
};
};

fetchMissionData();
}, [supabase, session?.user]);
Expand All @@ -207,7 +202,7 @@ const PlanetHuntersSteps = () => {
{selectedMission.id === 2 && <StarterTelescopeTess />}
{selectedMission.id === 3 && <PlanetTypeCommentForm />}
{selectedMission.id === 4 && <VotePlanetClassifictions />}
{selectedMission.id === 5 && <PlanetTemperatureForm />}
{selectedMission.id === 5 && <PlanetHuntersTemperatureWrapper />}
{selectedMission.id === 6 && <PHClassificationGenerator />}
{selectedMission.id === 1000 && <FirstTelescopeClassification anomalyid={"6"} />}
</center>
Expand Down Expand Up @@ -248,8 +243,8 @@ const PlanetHuntersSteps = () => {
<p className="text-xl font-bold">{completedCount}</p>
</div>
</div>
)
}
);
};

const filteredSteps = steps.filter((step) => step.chapter === currentChapter);

Expand Down
Loading

0 comments on commit 9d2f935

Please sign in to comment.