Spaces:
Sleeping
Sleeping
Update database_connection.py
Browse files- database_connection.py +4 -4
database_connection.py
CHANGED
|
@@ -32,14 +32,14 @@ class DatabaseConnection:
|
|
| 32 |
return pd.DataFrame()
|
| 33 |
|
| 34 |
def add_feedback(self, course: str, stanine: int, gwa: float, strand: str,
|
| 35 |
-
rating:
|
| 36 |
"""Add new feedback to the database"""
|
| 37 |
try:
|
| 38 |
# Try the original structure first (matching the existing data)
|
| 39 |
url = f"{self.base_url}/student_feedback_counts"
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
rating_str = rating
|
| 43 |
|
| 44 |
data = {
|
| 45 |
"course": course,
|
|
@@ -59,7 +59,7 @@ class DatabaseConnection:
|
|
| 59 |
# If the above fails, try the API structure you provided
|
| 60 |
try:
|
| 61 |
print("Trying alternative API structure...")
|
| 62 |
-
feedback_type =
|
| 63 |
|
| 64 |
import hashlib
|
| 65 |
student_data = f"{stanine}_{gwa}_{strand}_{hobbies}"
|
|
|
|
| 32 |
return pd.DataFrame()
|
| 33 |
|
| 34 |
def add_feedback(self, course: str, stanine: int, gwa: float, strand: str,
|
| 35 |
+
rating: int, hobbies: str) -> bool:
|
| 36 |
"""Add new feedback to the database"""
|
| 37 |
try:
|
| 38 |
# Try the original structure first (matching the existing data)
|
| 39 |
url = f"{self.base_url}/student_feedback_counts"
|
| 40 |
|
| 41 |
+
# Convert integer rating to string format for database
|
| 42 |
+
rating_str = "like" if rating == 1 else "dislike"
|
| 43 |
|
| 44 |
data = {
|
| 45 |
"course": course,
|
|
|
|
| 59 |
# If the above fails, try the API structure you provided
|
| 60 |
try:
|
| 61 |
print("Trying alternative API structure...")
|
| 62 |
+
feedback_type = "like" if rating == 1 else "dislike"
|
| 63 |
|
| 64 |
import hashlib
|
| 65 |
student_data = f"{stanine}_{gwa}_{strand}_{hobbies}"
|