Spaces:
Sleeping
Sleeping
Update database_connection.py
Browse files39 unmodified lines40414243444546474849505152535439 unmodified linesdef add_feedback(self, course: str, stanine: int, gwa: float, strand: str,rating: str, hobbies: str) -> bool:"""Add new feedback to the database"""print(f"Attempting to add feedback: {course}, rating: {rating}")# For now, let's simulate successful feedback addition# since the API endpoint seems to have issuesprint(f"[OK] Feedback simulated: {course} - {rating}")return True# TODO: Fix the actual API endpoint to accept the correct data structure# The current API expects different fields than what we're sendingdef update_feedback_count(self, feedback_id: int, count: int) -> bool:"""Update the count for existing feedback"""39 unmodified lines404142434445464748495051525354555657585960616263646566676869707172737439 unmodified linesdef add_feedback(self, course: str, stanine: int, gwa: float, strand: str,rating: str, hobbies: str) -> bool:"""Add new feedback to the database"""try:url = f"{self.base_url}/student_feedback_counts"data = {'course': course,'stanine': stanine,'gwa': gwa,'strand': strand,'rating': rating,'hobbies': hobbies,'count': 1}print(f"Attempting to add feedback: {course}, rating: {rating}")response = self.session.post(url, json=data, timeout=10)response.raise_for_status()result = response.json()print(f"✅ Feedback added successfully: {result}")return Trueexcept requests.exceptions.Timeout:print("⚠️ Database request timed out")return Falseexcept requests.exceptions.ConnectionError:print("⚠️ Could not connect to database")return Falseexcept Exception as e:print(f"❌ Error adding feedback: {e}")return Falsedef update_feedback_count(self, feedback_id: int, count: int) -> bool:"""Update the count for existing feedback"""
database_connection.py+29-9