Skip to content

Individual Contribution Section Mehmet Said Yolcu

Said Yolcu edited this page May 12, 2023 · 1 revision

Member

Name: Mehmet Said Yolcu
Group: 5

Contributions

Week 7 (13.04.23 - 19.04.23)
    Description Type of Work Issue Time Spent
    Attending Weekly Team Meeting #7 Discussion - 1 hour 30 mins
Week 8 (20.04.23 - 26.04.23)
    Description Type of Work Issue Time Spent
    Learning Docker Research - 4 hours
    Learning NodeJS Research - 5 hours
    Search For A Sample API Research #283 2 hours
Week 9 (27.04.23 - 03.05.23)
    Description Type of Work Issue Time Spent
    Attending Weekly Team Meeting #8 Discussion - 2 hours
Week 10 (04.05.23 - 10.05.23)
    Description Type of Work Issue Time Spent
    Attending Weekly Team Meeting #9 Discussion - 2 hours
    Implementing a Post Endpoint Feature #285 6 hours
    Implementing a Get Endpoint Feature #284 4 hours
Week 11 (11.05.23 - 17.05.23)
    Description Type of Work Issue Time Spent
    Attending Weekly Team Meeting #10 Discussion - 1 hour 30 mins
    Creating Top Games Frontend Page Feature #324 4 hours
    Writing Unit Tests For Top Games Endpoints Test #355 5 hours
    Creating Individual Contribution Section for Milestone Report Documentation #335 3 hours
    Creating a API Documentation Page Template Documentation #306 2 hours
    Creating a Documentation Page for Game By Top Games API Documentation #273 2 hours

Third Party APIs

SteamSpy is a platform that hosts a multitude of endpoints to steam game statistics

Utilized endpoints

GET: Top Games

Returns the top 100 of games according to their playing numbers
route: https://www.steamspy.com/api.php?request=top100forever

Created API Functions

POST: Insert Top Games

Allows users to search for the 100 top games from SteamSpy's database. Users can input the number of games in the request body, and the endpoint will issue a request to url(https://www.steamspy.com/api.php?request=top100forever) of the SteamSpy API to obtain the informations about top 100 games. These informations for top n of these games are then stored in the database together with the user's email address provided in the request body.
route: api/v1/games/topgames

GET: Get Top Games Responses via Email

Allows users to access a ordered list of the games(based on the playing numbers) they have previously searched. Accomplishes that by querying the database with the user's email address, which is provided in the request as a query parameter
route: api/v1/games/topgames

For a detailed documentation, visit this page.

Unit Tests

For the unit tests JEST framework is used. Regarding the use of JEST framework for unit tests, it is worth noting that this approach allows for a more robust and comprehensive testing process. By implementing various tests, covering each possible scenario, we can ensure that the code is functioning as expected under different conditions and inputs.

POST /topgames

These tests are responsible for ensuring that the API endpoint POST /api/v1/games/topgames works correctly when valid data is provided in the request body. It should return a HTTP status code of 201 stating some database objects are created and a success message if all necessary fields are provided.

Test Cases:

  • Case 1: When correct data is provided, it should return status code 201 and a success message
  test("should respond with status code 201 and a success message in json with correct data  ", async function () {
        const response = await request(app).post(url).send(correctPostData);

        expect(response.status).toEqual(201);
        expect(response.headers["content-type"]).toMatch(/json/);
        expect(response.body.status).toEqual("success");
        expect(response.body.message).toEqual(
            "Info for top games is inserted into DB successfully"
        );
    });
  • Case 2: When email field is missing, it should return status code 400 and an error message stating that all necessary fields should be provided.
   test("should respond with status code 400 and a error message in json with missing email", async function () {
        const response = await request(app).post(url).send(missingEmailData);

        expect(response.status).toEqual(400);
        expect(response.headers["content-type"]).toMatch(/json/);
        expect(response.body.status).toEqual("Error");
        expect(response.body.message).toEqual(
            "You should provide all the necessary fields"
        );
    });
  • Case 3: When number field is missing, it should return status code 400 and an error message stating that all necessary fields should be provided.
     test("should respond with status code 400 and a error message in json with missing number", async function () {
        const response = await request(app).post(url).send(missingNumberData);

        expect(response.status).toEqual(400);
        expect(response.headers["content-type"]).toMatch(/json/);
        expect(response.body.status).toEqual("Error");
        expect(response.body.message).toEqual(
            "You should provide all the necessary fields"
        );
    });

GET /topgames

These test are responsible for ensuring that the API endpoint GET /api/v1/games/topgames works correctly when valid data is provided in the query parameter. It should return a HTTP status code of 200 and game from the database if a registered user's email address is provided. To be able to test the GET endpoint, first some seed data is created, upon completion of the tests this data is removed in order not to leave dirty data in the database.

Test Cases:

  • Case 1: When a registered user's email is provided, it should return status code 200 and previous responses that is made to /topgames endpoint that is associated with that user's email address.
   test("should respond with status code 200 and a success message in json with correct data  ", async function () {
        const response = await request(app).get(registeredUserUrl);
        expect(response.status).toEqual(200);
        expect(response.headers["content-type"]).toMatch(/json/);
        expect(response.body.games.length).toEqual(2);
        expect(response.body.games[0].user_email).toBeDefined();
        expect(response.body.games[0].name).toBeDefined();
        expect(response.body.games[0].developer).toBeDefined();
        expect(response.body.games[0].publisher).toBeDefined();
        expect(response.body.games[0].owners).toBeDefined();
        expect(response.body.games[0].average_forever).toBeDefined();
        expect(response.body.games[0].average_2weeks).toBeDefined();
        expect(response.body.games[0].median_forever).toBeDefined();
        expect(response.body.games[0].median_2weeks).toBeDefined();
        expect(response.body.games[0].price).toBeDefined();
        expect(response.body.games[0].initialprice).toBeDefined();
        expect(response.body.games[0].discount).toBeDefined();
        expect(response.body.games[0].ccu).toBeDefined();
        expect(response.body.games[0].createdAt).toBeDefined();
    });
  • Case 2: When a non-registered user's email is provided, it should return an status code 400.
    test("should return an empty array with a non registered user email ", async function () {
        const response = await request(app).get(nonRegisteredUserUrl);

        expect(response.status).toEqual(400);
    });

Sample Calls

Response

( 100 hundred such fields, only one of them is shown)

{
    "570": {
        "appid": 570,
        "name": "Dota 2",
        "developer": "Valve",
        "publisher": "Valve",
        "score_rank": "",
        "positive": 1631735,
        "negative": 347240,
        "userscore": 0,
        "owners": "200,000,000 .. 500,000,000",
        "average_forever": 37276,
        "average_2weeks": 1356,
        "median_forever": 917,
        "median_2weeks": 712,
        "price": "0",
        "initialprice": "0",
        "discount": "0",
        "ccu": 541322
    },
}

Practice App Api Sample Post Call(POST /api/v1/games/topgames)

Request

{
    "userEmail":"[email protected]",
    "number":4
}

Response

{
    "status": "success",
    "message": "Info for top games is inserted into DB successfully"
}

Practice App Api Sample Get Call(GET /api/v1/games/topgames?userEmail=[email protected])

Response

{
    "games": [
        {
            "user_email": "[email protected]",
            "name": "Dota 2",
            "developer": "Valve",
            "publisher": "Valve",
            "owners": "200,000,000 .. 500,000,000",
            "average_forever": "37276",
            "average_2weeks": "1356",
            "median_forever": "917",
            "median_2weeks": "712",
            "price": "0",
            "initialprice": "0",
            "discount": "0",
            "ccu": "541322",
            "createdAt": "2023-05-12T19:53:07.846Z"
        },
        {
            "user_email": "[email protected]",
            "name": "Counter-Strike: Global Offensive",
            "developer": "Valve, Hidden Path Entertainment",
            "publisher": "Valve",
            "owners": "50,000,000 .. 100,000,000",
            "average_forever": "27989",
            "average_2weeks": "725",
            "median_forever": "5680",
            "median_2weeks": "301",
            "price": "0",
            "initialprice": "0",
            "discount": "0",
            "ccu": "1364757",
            "createdAt": "2023-05-12T19:53:07.846Z"
        },
        {
            "user_email": "[email protected]",
            "name": "PUBG: BATTLEGROUNDS",
            "developer": "KRAFTON, Inc.",
            "publisher": "KRAFTON, Inc.",
            "owners": "50,000,000 .. 100,000,000",
            "average_forever": "22476",
            "average_2weeks": "697",
            "median_forever": "6403",
            "median_2weeks": "181",
            "price": "0",
            "initialprice": "0",
            "discount": "0",
            "ccu": "285068",
            "createdAt": "2023-05-12T19:53:07.848Z"
        },
        {
            "user_email": "[email protected]",
            "name": "Rust",
            "developer": "Facepunch Studios",
            "publisher": "Facepunch Studios",
            "owners": "20,000,000 .. 50,000,000",
            "average_forever": "20195",
            "average_2weeks": "1182",
            "median_forever": "3164",
            "median_2weeks": "434",
            "price": "3999",
            "initialprice": "3999",
            "discount": "0",
            "ccu": "104270",
            "createdAt": "2023-05-12T19:53:07.847Z"
        }
    ]
}

Challenges

The main challenge I have faced is using Git. I did have prior expreience in using Git but I did not know it to this extent. Another challenge I have faced was using MongoDB. I have used PostgreSQL and MySQL before but Mongo is whole another planet. I had a hard time getting comfortable with it. Third challenge I faced was using Docker. I knew Docker beforehand but I have used in in a small extent. Level of Dockerization in this project was hard to understand for me.



💻 Meeting Notes

Cmpe 352
Cmpe 451

📝 Requirements


🪧 Diagrams


📬 Deliverables

Cmpe 352
Cmpe 451

🎇 General Contributions

Cmpe 352 Contributions

Milestone 1
Final Milestone

Cmpe 451 Contributions

Milestone 1
Milestone 2
Final Milestone

📕 Mock Up


🕵️ User Scenario



📝 RAM


📚 Research


📑 Templates


📱 Practice App

API Documentation for Practice App
Clone this wiki locally