From 333b2ae71ebe21bf5c475b3a1f54e48f7f4a771a Mon Sep 17 00:00:00 2001 From: Arlo Date: Fri, 22 Mar 2024 23:53:25 +0000 Subject: [PATCH] Add Leaderboard --- Leaderboard.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Leaderboard.md diff --git a/Leaderboard.md b/Leaderboard.md new file mode 100644 index 0000000..a441d2a --- /dev/null +++ b/Leaderboard.md @@ -0,0 +1,40 @@ +# Leaderboard API Endpoint + +## GET `/api/leaderboard` + +Returns the highest test data from each user as a JSON array. The data includes metrics such as username, words per minute (WPM), accuracy percentage, the time taken for the test, and the length of the test for a comprehensive overview of user performance. + +## Responses + +- `200 OK`: Successfully retrieves the leaderboard data. +- `404 Not Found`: Indicates that the leaderboard was not found. +- `500 Internal Server Error`: Indicates an issue with accessing the database. + +## Example Response + +```json +[ + { + "username": "user1", + "wpm": 75, + "accuracy": 97, + "test_time": 120, + "test_length": 250 + }, + { + "username": "user2", + "wpm": 73, + "accuracy": 95, + "test_time": 115, + "test_length": 240 + } +] +``` + +## Fields + +- `username`: The name of the user. +- `wpm`: Words per minute, indicating the typing speed. +- `accuracy`: The accuracy of the user's typing, in percentage. +- `test_time`: The total time taken to complete the test, in seconds. +- `test_length`: The length of the test, typically measured in number of words. \ No newline at end of file