Skip to content

Instantly share code, notes, and snippets.

@ewega
Created May 2, 2024 15:26
Show Gist options
  • Save ewega/38b7e010e71d88efd2b38fa58f0918a2 to your computer and use it in GitHub Desktop.
Save ewega/38b7e010e71d88efd2b38fa58f0918a2 to your computer and use it in GitHub Desktop.
# Context Document
## Business Logic Summary
The application is a book management system. It allows users to view a list of books, each with details such as the title, author, cover image, and rating. The data is stored in a SQL database and accessed through the [`BookDatabaseImpl`](command:_github.copilot.openSymbolInFile?%5B%22src%2Fmain%2Fjava%2Fcom%2Fgithub%2Fdemo%2Fservice%2FBookDatabaseImpl.java%22%2C%22BookDatabaseImpl%22%5D "src/main/java/com/github/demo/service/BookDatabaseImpl.java") class, which implements the `BookDatabase` interface.
<!-- Could add that this is a microservice application connected to XYZ app. Also relevant info to include:
- How it is deployed (e.g. Docker, Kubernetes, AWS, etc.)
- What other services it connects to (e.g. SQL database, Redis cache, etc.)
-->
## Ticket: Add Average Rating Feature
**Title:** Add the ability to return the average rating of books for a specific author to the frontend
**Description:** We need to enhance our application to provide more insightful data to our users. Specifically, we want to display the average rating of books for a specific author. This feature will allow users to get a quick overview of an author's overall reception in our community.
**Requirements:**
1. Update the `BookDatabase` interface and its implementation [`BookDatabaseImpl`](command:_github.copilot.openSymbolInFile?%5B%22src%2Fmain%2Fjava%2Fcom%2Fgithub%2Fdemo%2Fservice%2FBookDatabaseImpl.java%22%2C%22BookDatabaseImpl%22%5D "src/main/java/com/github/demo/service/BookDatabaseImpl.java") to include a method that calculates and returns the average rating of books for a specific author.
2. Update the `BookService` class to call the new method in the `BookDatabase` interface.
3. Update the `BookServlet` class to include the average rating in the response sent to the frontend.
4. Ensure that the average rating is correctly calculated and formatted (rounded to one decimal place).
5. Include appropriate unit tests to verify the new functionality.
## Database Table: Books
| book_id | book_name | author | rating | cover | details |
|---------|-----------|--------|--------|-------|---------|
| 1 | Scrum: The Art of Doing Twice the Work in Half the Time | Jeff Sutherland | 5 | scrum.jpg | ... |
| 2 | The Lean Startup: How Constant Innovation Creates Radically Successful Businesses | Eric Ries | 2 | lean.jpg | ... |
| 3 | Crossing the Chasm | Geoffrey A. Moore | 4 | chasm.jpg | ... |
| 4 | The Pragmatic Programmer: From Journeyman to Master | David Thomas | 1 | pragmatic.jpg | ... |
| 5 | The Mythical Man-Month: Essays on Software Engineering | Frederick P. Brooks Jr. | 5 | month.jpg | ... |
| 6 | Don't Make Me Think, Revisited: A Common Sense Approach to Web Usability | Steve Krug | 3 | think.jpg | ... |
<!-- Could also include APIs it connects to externally -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment