Skip to content

Commit

Permalink
reset to main backend
Browse files Browse the repository at this point in the history
  • Loading branch information
MaHaWo committed Dec 17, 2024
1 parent 43f01aa commit aace132
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion mondey_backend/openapi.json

Large diffs are not rendered by default.

37 changes: 1 addition & 36 deletions mondey_backend/src/mondey_backend/routers/milestones.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from fastapi import APIRouter
from fastapi import HTTPException
from fastapi import UploadFile
from sqlalchemy.orm import lazyload
from sqlmodel import col
Expand All @@ -11,7 +10,6 @@
from ..dependencies import SessionDep
from ..models.milestones import Language
from ..models.milestones import Milestone
from ..models.milestones import MilestoneAnswerSession
from ..models.milestones import MilestoneGroup
from ..models.milestones import MilestoneGroupPublic
from ..models.milestones import MilestonePublic
Expand Down Expand Up @@ -47,23 +45,17 @@ def get_milestone(session: SessionDep, milestone_id: int):
return get(session, Milestone, milestone_id)

@router.get(
"/milestone-groups/childid={child_id}",
response_model=list[MilestoneGroupPublic],
"/milestone-groups/{child_id}", response_model=list[MilestoneGroupPublic]
)
def get_milestone_groups(
session: SessionDep,
current_active_user: CurrentActiveUserDep,
child_id: int,
):
child = get_db_child(session, current_active_user, child_id)

if not child:
raise HTTPException(status_code=404, detail="Child not found")

milestone_answer_session = get_or_create_current_milestone_answer_session(
session, current_active_user, child
)

milestone_ids = list(milestone_answer_session.answers.keys())

milestone_groups = session.exec(
Expand All @@ -78,33 +70,6 @@ def get_milestone_groups(

return milestone_groups

@router.get(
"/milestone-groups/answersession_id={answersession_id}",
response_model=list[MilestoneGroupPublic],
)
def get_milestone_groups_for_answersession(
session: SessionDep,
answersession_id: int,
):
answersession = session.get(MilestoneAnswerSession, answersession_id)

if not answersession:
raise HTTPException(status_code=404, detail="Answersession not found")

milestone_ids = list(answersession.answers.keys())

milestone_groups = session.exec(
select(MilestoneGroup)
.order_by(col(MilestoneGroup.order))
.options(
lazyload(
MilestoneGroup.milestones.and_(col(Milestone.id).in_(milestone_ids))
)
)
).all()

return milestone_groups

@router.post("/submitted-milestone-images/{milestone_id}")
async def submit_milestone_image(
session: SessionDep,
Expand Down
2 changes: 1 addition & 1 deletion mondey_backend/src/mondey_backend/routers/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def leq(val: float, lim: float) -> bool:
else:
lim_lower = stat.avg_score - 2 * stat.stddev_score
lim_upper = stat.avg_score - stat.stddev_score

print("eval: ", lim_lower, lim_upper, stat.avg_score, score)
if leq(score, lim_lower):
return TrafficLight.red.value
elif score > lim_lower and leq(score, lim_upper):
Expand Down
7 changes: 7 additions & 0 deletions mondey_backend/tests/utils/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_online_statistics_computation_too_little_data():

def test_get_score_statistics_by_age(session):
answers = session.exec(select(MilestoneAnswer)).all()
print(answers)
# which answers we choose here is arbitrary for testing, we just need to make sure it's fixed and not empty
child_ages = {
1: 5,
Expand Down Expand Up @@ -212,6 +213,12 @@ def test_calculate_milestone_statistics_by_age(statistics_session):

# we have nothing new for everything else
for age in range(0, len(mscore.scores)):
print(
age,
mscore.scores[age].count,
mscore.scores[age].avg_score,
mscore.scores[age].stddev_score,
)
if age != 8:
assert mscore.scores[age].count == 12
avg = 0 if age < 5 else min(1 * age - 5, 3)
Expand Down

0 comments on commit aace132

Please sign in to comment.