Skip to content

Commit

Permalink
final version: todo last readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanaliouchouche committed May 24, 2024
1 parent 0417d66 commit 4da36d7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,7 @@ cython_debug/
*.ipynb

# Vscode
.vscode/
.vscode/

# DS_Store
*.DS_Store
34 changes: 17 additions & 17 deletions app/js/end_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ document.addEventListener('DOMContentLoaded', () => {
difficulty: difficulty
};

// console.log('data to be sent:');
// console.log(JSON.stringify(postData));

// fetch('http://127.0.0.1:8000/add_score', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify(postData)
// })
// .then(response => response.json())
// .then(data => {
// console.log('Success:', data);
// })
// .catch((error) => {
// console.error('Error:', error);
// });
console.log('data to be sent:');
console.log(JSON.stringify(postData));

fetch('http://localhost:8000/add_score', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(postData)
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
.catch((error) => {
console.error('Error:', error);
});

// Get the podium from the server
fetch('http://localhost:8000/scores')
Expand Down
14 changes: 4 additions & 10 deletions endpoints/predict_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ async def get_labels():


@app.get("/scores")
async def get_scores(mode: str, difficulty: str):
async def get_scores():
"""
Function to return the top 3 scores from the database
filtered by the given mode and difficulty.
Function to return all scores from the database without any filters.
It returns a dictionary with the scores.
score1: { user: user1,
Expand Down Expand Up @@ -205,14 +204,9 @@ async def get_scores(mode: str, difficulty: str):

data = _data[1]
df = pd.DataFrame(data)
df_filtered = df[(df['mode'] == mode) & (df['difficulty'] == difficulty)]

df_filtered = df_filtered.sort_values(by=['score', 'mean_time'],
ascending=[False, True])

df_top3 = df_filtered.head(3)

scores = df_top3.to_dict(orient='records')
# Return the DataFrame as a dictionary without any filtering
scores = df.to_dict(orient='records')

return scores

Expand Down
14 changes: 4 additions & 10 deletions endpoints/predict_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ async def get_labels():


@app.get("/scores")
async def get_scores(mode: str, difficulty: str):
async def get_scores():
"""
Function to return the top 3 scores from the database
filtered by the given mode and difficulty.
Function to return all scores from the database without any filters.
It returns a dictionary with the scores.
score1: { user: user1,
Expand Down Expand Up @@ -207,14 +206,9 @@ async def get_scores(mode: str, difficulty: str):

data = _data[1]
df = pd.DataFrame(data)
df_filtered = df[(df['mode'] == mode) & (df['difficulty'] == difficulty)]

df_filtered = df_filtered.sort_values(by=['score', 'mean_time'],
ascending=[False, True])

df_top3 = df_filtered.head(3)

scores = df_top3.to_dict(orient='records')
# Return the DataFrame as a dictionary without any filtering
scores = df.to_dict(orient='records')

return scores

Expand Down

0 comments on commit 4da36d7

Please sign in to comment.