Spaces:
Sleeping
Sleeping
removed int response
Browse files- app.py +7 -6
- gamification/routes.py +1 -5
app.py
CHANGED
|
@@ -491,20 +491,21 @@ def handle_change(change):
|
|
| 491 |
# add everybodies points and add it to the leaderboard table
|
| 492 |
collections = db.list_collection_names()
|
| 493 |
if "LeaderBoard" not in collections:
|
| 494 |
-
|
| 495 |
users = get_all_users()
|
| 496 |
for user in users:
|
|
|
|
| 497 |
points = get_all_simple_points_func(userId=str(user['_id']))
|
| 498 |
tempDreamJob = get_dream_job(userId=str(user['_id']))
|
| 499 |
dreamJob = tempDreamJob if type(tempDreamJob)==str else "IncompleteProfile"
|
| 500 |
|
| 501 |
create_leaderboard_ranking(LeaderBoardRanking(userId=str(user['_id']),firstName=user['first_name'],lastName=user['last_name'],totalpoints=points.totalpoints,lastUpdated=datetime.now(),careerPath=dreamJob,))
|
| 502 |
leaderBoardcollection = db['LeaderBoard']
|
| 503 |
-
index = leaderBoardcollection.create_index([
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
print("index",index)
|
| 508 |
else:
|
| 509 |
if change['operationType'] == 'insert':
|
| 510 |
# Extract the full document
|
|
|
|
| 491 |
# add everybodies points and add it to the leaderboard table
|
| 492 |
collections = db.list_collection_names()
|
| 493 |
if "LeaderBoard" not in collections:
|
| 494 |
+
print("No leaderboard so creating one now")
|
| 495 |
users = get_all_users()
|
| 496 |
for user in users:
|
| 497 |
+
print("inserting user",f"user id {user['_id']}")
|
| 498 |
points = get_all_simple_points_func(userId=str(user['_id']))
|
| 499 |
tempDreamJob = get_dream_job(userId=str(user['_id']))
|
| 500 |
dreamJob = tempDreamJob if type(tempDreamJob)==str else "IncompleteProfile"
|
| 501 |
|
| 502 |
create_leaderboard_ranking(LeaderBoardRanking(userId=str(user['_id']),firstName=user['first_name'],lastName=user['last_name'],totalpoints=points.totalpoints,lastUpdated=datetime.now(),careerPath=dreamJob,))
|
| 503 |
leaderBoardcollection = db['LeaderBoard']
|
| 504 |
+
# index = leaderBoardcollection.create_index([
|
| 505 |
+
# ('lastName', 1),
|
| 506 |
+
# ('totalpoints', -1)
|
| 507 |
+
# ])
|
| 508 |
+
# print("index",index)
|
| 509 |
else:
|
| 510 |
if change['operationType'] == 'insert':
|
| 511 |
# Extract the full document
|
gamification/routes.py
CHANGED
|
@@ -42,10 +42,6 @@ def create_feedback(feedback:Feedback,authorization: str = Header(...))->bool:
|
|
| 42 |
raise HTTPException(status_code=500,detail=f"{e}")
|
| 43 |
|
| 44 |
|
| 45 |
-
@gamification.post("/get-leaderboard",tags=["user"])
|
| 46 |
-
def get_leaderboard_details():
|
| 47 |
-
pass
|
| 48 |
-
|
| 49 |
@gamification.get("/get-advanced-user-points",tags=["user"])
|
| 50 |
def get_points(authorization: str = Header(...))->IndividualUserLevel:
|
| 51 |
# Extract the token from the Authorization header (Bearer token)
|
|
@@ -112,7 +108,7 @@ def get_level_details_and_information()->List[UserLevel]:
|
|
| 112 |
|
| 113 |
|
| 114 |
@gamification.patch("/edit-level",tags=["admin"])
|
| 115 |
-
def edit_level(level_obj:EditableUserLevel)
|
| 116 |
result = edit_level_func(level_id=level_obj.levelId,levelName=level_obj.levelName,careerPath=level_obj.careerPath,minPoints=level_obj.minPoints,maxPoints=level_obj.maxPoints,levelNumber=level_obj.levelNumber)
|
| 117 |
|
| 118 |
return {"message":result}
|
|
|
|
| 42 |
raise HTTPException(status_code=500,detail=f"{e}")
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
@gamification.get("/get-advanced-user-points",tags=["user"])
|
| 46 |
def get_points(authorization: str = Header(...))->IndividualUserLevel:
|
| 47 |
# Extract the token from the Authorization header (Bearer token)
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
@gamification.patch("/edit-level",tags=["admin"])
|
| 111 |
+
def edit_level(level_obj:EditableUserLevel):
|
| 112 |
result = edit_level_func(level_id=level_obj.levelId,levelName=level_obj.levelName,careerPath=level_obj.careerPath,minPoints=level_obj.minPoints,maxPoints=level_obj.maxPoints,levelNumber=level_obj.levelNumber)
|
| 113 |
|
| 114 |
return {"message":result}
|