Skip to content

Individual Contribitions for Alperen Bırçak

Alperen edited this page May 12, 2023 · 2 revisions

Contributions

Week 7 (13.04.23 - 19.04.23 Mostly Spring Break)
    Description Type of Work Issue Time Spent
    Attending Weekly Team Meeting #7 Discussion - 1 hour 30 mins
    Learning How To Use Git Effectively Research - 4 hours
Week 8 (20.04.23 - 26.04.23)
    Description Type of Work Issue Time Spent
    Research about React Form Hooks Research #123 5 hours
    Searching For an Third Party API to Use In Our Practice App Research #144 4 hours
Week 9 (27.04.23 - 03.05.23)
    Description Type of Work Issue Time Spent
    Attending and Planning the App in Meeting Discussion - 2 hours
    Setting Up the Basic Front-End Environment for Practice App Feature #149 2 hours
Week 10 (04.05.23 - 10.05.23)
    Description Type of Work Issue Time Spent
    Moderating Frontend Team Meeting Discussion - 1 hour 45 mins
    Creating the Form Builder Component Feature #165 2 hours
    Leveraging React Router Loaders for Dynamic Page Building #176 2 hours
    Creating a User Login Page for Improved App Functionality #178 2 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
    Implementing a The Endpoints for Practice App Feature #215 5 hours
    Improve the Aesthetics of Frontend Feature #200 5 hours
    Enhancing FormBuilder Component with New Input Field Types #220 5 hours
    Implementing Tests for Deal Endpoints #299 5 hours
    Creating a Documentation Page for Game Reviews API Documentation Page 2 hours
    Creating Individual Contribution Section for Milestone Report Documentation Page 4 hours

Third Party APIs

The Cheap Shark API is a web-based service that provides access to historical and current pricing information for video games across multiple platforms. It allows developers to retrieve data such as game titles, prices, discounts, and store information, enabling them to create applications and services that help users find the best deals on games. CheapShark API. The purpose of my page is to aid the user in finding good deals for games they might like to purchase.

Utilized endpoints

GET: List of Deals

Get a paged list of deals matching any number of criteria, all the filtering parameters are optional.
route: https://www.cheapshark.com/api/1.0/deals

For a detailed documentation, you can check here.

Created API Functions

POST: Search and Save Deals

This is an endpoint that creates a new request and history record for a user and saves it to a database. It takes in a request, response, and next as parameters and extracts the user's email, upper price, title, deal count, minimum rating, and on sale data from the request body. It then uses Axios to make a request to an external API to retrieve a list of deals based on the extracted data. The returned data is mapped into a new object and saved to the database. If there are any errors during this process, they are caught and handled accordingly by logging them or throwing a custom error. Finally, a successful response is sent with a message indicating that the history has been inserted into the database.
route: api/v1/games/deal

GET: Get Game Deal Request History By Email

This is an endpoint that retrieves a user's "Deal Request History" based on their email address. It checks if the email field is present in the request, and sends an error response if it's missing. The endpoint then queries the database to retrieve the deal requests associated with the specified email, sorts them by creation date and returns them as a JSON response with a 200 status code.
route: api/v1/games/deal

For a detailed documentation, visit this page.

Unit Tests

The JEST framework is used for unit testing. Using JEST for unit tests provides several benefits, including a more thorough and comprehensive testing process. By creating multiple tests that cover all possible scenarios, we can verify that the code performs as intended under different inputs and conditions, resulting in a more robust overall codebase.

POST /review

The purpose of these tests is to verify the correct functionality of the "POST /api/v1/games/deal" API endpoint when valid data is provided in the request body. The expected outcome is an HTTP status code of 201, indicating that the necessary database objects have been created, along with a success message.

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(
      "History is inserted to database 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"
    );
  });

GET /review

The purpose of these tests is to verify the proper functioning of the "GET /api/v1/games/review" API endpoint when valid data is provided in the query parameter. If a registered user's email address is provided, the endpoint should return an HTTP status code of 200 along with game reviews retrieved from the database. Otherwise, it should return an error message indicating that the requested resource was not found. Prior to testing the GET endpoint, seed data is generated, and once the tests are complete, this data is removed to prevent lingering artifacts in the database.

Test Cases:

  • Case 1: When a registered user's email is provided, it should return status code 200 and all game reviews 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[0].user_email).toBeDefined();
    expect(response.body[0].title).toBeDefined();
    expect(response.body[0].upper_price).toBeDefined();
    expect(response.body[0].deals).toBeDefined();
  });
  • Case 2: When a non-registered user's email is provided, it should return status code 404 and a not found error message.
    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(200);
    expect(response.headers["content-type"]).toMatch(/json/);
    expect(response.body.length).toEqual(0);
  });

Sample Calls

Sample Call to CheapShark API GET .../deals

  • Request
https://www.cheapshark.com/api/1.0/deals?storeID=1&pageSize=2&upperPrice=15&title=Warrior&steamRating=50&onSale=true
  • Response
[
    {
      internalName: 'IRONWARRIORST72TANKCOMMAND',
      title: 'Iron Warriors: T - 72 Tank Command',
      metacriticLink: '/game/pc/iron-warriors-t-72-tank-command',
      dealID: 'xaZ0ByYNhZ5wApWcoPuWDNBE8QftmLeevJDBICb%2F5Ic%3D',
      storeID: '1',
      gameID: '1265',
      salePrice: '0.99',
      normalPrice: '4.99',
      isOnSale: '1',
      savings: '80.160321',
      metacriticScore: '56',
      steamRatingText: 'Mixed',
      steamRatingPercent: '63',
      steamRatingCount: '251',
      steamAppID: '1670',
      releaseDate: 1148428800,
      lastChange: 1683770023,
      dealRating: '7.8',
      thumb: 'https://cdn.cloudflare.steamstatic.com/steam/apps/1670/capsule_sm_120.jpg?t=1574192407'
    },
    {
      internalName: 'WARSANDWARRIORSJOANOFARC',
      title: 'Wars and Warriors  Joan of Arc',
      metacriticLink: '/game/pc/wars-and-warriors-joan-of-arc',
      dealID: 'c0%2Bp2ij28bsJEYtb097Ip7laKhu6Uy7eGpIrc9RacO8%3D',
      storeID: '1',
      gameID: '93314',
      salePrice: '1.74',
      normalPrice: '6.99',
      isOnSale: '1',
      savings: '75.107296',
      metacriticScore: '60',
      steamRatingText: 'Very Positive',
      steamRatingPercent: '94',
      steamRatingCount: '242',
      steamAppID: '294590',
      releaseDate: 1076112000,
      lastChange: 1683400829,
      dealRating: '6.8',
      thumb: 'https://cdn.cloudflare.steamstatic.com/steam/apps/294590/capsule_sm_120.jpg?t=1681167402'
    }
  ]
}

Sample Call Implemented API Function POST .../api/v1/games/deal

  • Request
{
"title": "Warrior",
"upperPrice": "15",
"dealCount": "2",
"minimumRating": "50",
"onSale": true,
"userEmail": "[email protected]"
}
  • Response
{
"status": "success",
"message": "History is inserted to database successfully"
}

Sample Call Implemented API Function GET .../api/v1/games/deal?userEmail=[email protected]

  • Response
   [
{
"_id": "645eb129adca0ee80bb3e23c",
"user_email": "[email protected]",
"title": "Warrior",
"upper_price": 15,
"deals": [
{
"title": "Iron Warriors: T - 72 Tank Command",
"sale_price": "0.99",
"normal_price": "4.99",
"steam_rating_text": "Mixed",
"rating": "63%",
"_id": "645eb129adca0ee80bb3e23d"
},
{
"title": "Wars and Warriors  Joan of Arc",
"sale_price": "1.74",
"normal_price": "6.99",
"steam_rating_text": "Very Positive",
"rating": "94%",
"_id": "645eb129adca0ee80bb3e23e"
}
],
"createdAt": "2023-05-12T21:35:37.285Z",
"updatedAt": "2023-05-12T21:35:37.285Z",
"__v": 0
},
{
"_id": "645eb0143379c772a2ecd212",
"user_email": "[email protected]",
"title": "Warrior",
"upper_price": 15,
"deals": [
{
"title": "Iron Warriors: T - 72 Tank Command",
"sale_price": "0.99",
"normal_price": "4.99",
"steam_rating_text": "Mixed",
"rating": "63%",
"_id": "645eb0143379c772a2ecd213"
},
{
"title": "Wars and Warriors  Joan of Arc",
"sale_price": "1.74",
"normal_price": "6.99",
"steam_rating_text": "Very Positive",
"rating": "94%",
"_id": "645eb0143379c772a2ecd214"
}
],
"createdAt": "2023-05-12T21:31:00.258Z",
"updatedAt": "2023-05-12T21:31:00.258Z",
"__v": 0
}
]
}
]

Challenges

Throughout this project, I encountered several challenges. Firstly, as someone who had not used test frameworks before, I found it challenging to work with Node.js and JEST testing framework. Secondly, we struggled with understanding the project description, which delayed our progress and resulted in a lot of time spent in meetings to ensure everyone was on the same page. Additionally, designing a front-end system for each API and developing a component system that can be easily used by all members proved to be a complex issue. Finally, selecting suitable technologies that accommodated team members' varying levels of experience also presented challenges. To overcome these obstacles in future projects, we must carefully evaluate technology choices, prioritize clear communication, and actively develop user-friendly design systems.



💻 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