feat: add tee selection and skip hole button

Co-authored-by: aider (openrouter/thinkingmachines/inkling-small:free) <aider@aider.chat>
This commit is contained in:
Jiří Stachandaider committed 2026-10-09 22:59:15 +02:00
1 parent 935f5bd85b
commit ad0032bea1
3 files changed
+30 -12

No files matched your search

+6 -4
View File
@@ -37,6 +37,7 @@ class Round(Base):
user_id = Column(Integer, ForeignKey("users.id"))
course_id = Column(Integer, ForeignKey("courses.id"))
status = Column(String, default="in_progress")
tee = Column(String, default="White")
class HoleScore(Base):
__tablename__ = "hole_scores"
@@ -82,7 +83,6 @@ HoleScore.round = relationship("Round", back_populates="hole_scores")
HoleScore.putts = relationship("Putt", back_populates="hole_score")
Putt.hole_score = relationship("HoleScore", back_populates="putts")
# Recreate DB for prototype if schema changed
if os.path.exists("backend/golf.db"):
os.remove("backend/golf.db")
@@ -133,11 +133,12 @@ def signup(req: SignupRequest):
class StartRoundRequest(BaseModel):
user_id: int
course_id: int
tee: str = "White"
@app.post("/round")
def start_round(req: StartRoundRequest):
db = SessionLocal()
round_obj = Round(user_id=req.user_id, course_id=req.course_id, status="in_progress")
round_obj = Round(user_id=req.user_id, course_id=req.course_id, status="in_progress", tee=req.tee)
db.add(round_obj)
db.commit()
db.refresh(round_obj)
@@ -147,7 +148,7 @@ def start_round(req: StartRoundRequest):
db.add(hs)
db.commit()
db.close()
return {"id": round_obj.id, "status": round_obj.status}
return {"id": round_obj.id, "status": round_obj.status, "tee": round_obj.tee}
@app.get("/course")
def get_course():
@@ -174,6 +175,7 @@ def get_round(round_id: int):
"user_id": round_obj.user_id,
"course_id": round_obj.course_id,
"status": round_obj.status,
"tee": round_obj.tee,
"holes": []
}
for hs in hole_scores:
@@ -197,7 +199,7 @@ def get_round(round_id: int):
"hole_info": {
"par": hole.par if hole else None,
"yardage_meters": hole.yardage_meters if hole else 0,
"tee": hole.tee if hole else "White"
"tee": round_obj.tee
}
})
db.close()