albendz / albendz-code-share Goto Github PK
View Code? Open in Web Editor NEWA place to keep code to share with others
A place to keep code to share with others
Support deletion of a single copy of a book through a REST API
DELETE
/book/{isbn}/copy/{id}
Returns 200 on success or 404 if copy or book does not exist.
This will work asynchronously. A deletion message will be placed on a Kafka deletion topic. The consumer of the topic will accept the message and delete the copy if it is available. If the copy is not available, a hold will be placed on the copy to a "deletion". When the copy is available again, it will be deactivated (soft delete) and no longer available to borrow. This requires the introduction of a new copy status for deleted copies.
If a copy ID is not provided, the first available copy will be deleted or a hold will be placed on the copy which has a most recently expiring loan. The deletion can take place after prior holds are satisfied.
Upon deletion of the last copy of a book, all holds are deleted on the book. The book itself will automatically become unavailable.
Deleted copies should not be counted in total copies of a book in book responses.
Add diagrams and documentation to project
Add diagram for ideal project and current.
Add logging and logging configuration. Consider exporting to a logging service.
Allow book loans to be checked in / returned in two ways:
This is an asynchronous operation. The REST call will queue a message in a kafka topic to check in a book.
The consumer of the kafka messages will retrieve the check in and check for holds. If there are active holds for that copy, automatically check out the book to the member and send a message to a check out topic.
Add more user information to member details and support editing of editable fields.
New user information:
Editable information:
Uneditable information:
New information to be added to member responses
Add more details to books that are searchable
Add additional genre information, tags, and series information to books to support searching for related content or checking tags. Also support multiple genres associated to a single book.
This ticket lists potential features that haven't been selected for development. All require further investigation.
Support editing book information through REST API
Create /book/{isbn} PUT operation to updated book information. Valid information that can be updated:
No adjusting number of copies yet.
Genre names can contain any characters. Update to restrict to only letters and spaces within the string.
Genres are valid if there are only letters and spaces.
Trailing spaces must be removed and genre names should be all lowercase. When retrieving genre information, convert to camel case.
Using tests run with @MicronautTest annotation and no mocking, test end to end scenarios for each feature.
Not a complete list, will need to consider all new implemented features until this is complete.
When uploading CSV for books with already existing ISBN, update book information.
Update title, author, genre, and publication date for CSV import. Also, add copies up to the copy number provided in the CSV but do not support deletion of copies.
Get all copies of book by ISBN
If a book has multiple copies, return a list with copy information about availability, identifiers, and metadata.
/book/{isbn}/copies
{
"isbn": "<isbn>",
"copies": [
{
"id": "<id>",
"status": "<status>",
"metadata": {}
}
]
}
NA
Split out the member functionality of the library service.
Allow users to place holds on a book
A user can create a hold on a book when they want to borrow a book that does not have available copies. This will create a hold entity in the holds table.
This operations is through a REST API: /book/{isbn}/hold with member and copy (optionally) in payload as with #18
This will place an asynchronous message on a kafka topic to place a hold. The kafka consumer will read the hold request and create the hold entity in the database.
If a member, book, or copy does not exist, return 404.
A user can only have 20 active holds. If a user has 20 hold already, return a 400.
We want code quality checks on each build.
Use Detekt to set up code quality rules. Use defaults initially and customize later as needed.
NA
The toResponse
method is being called in services which are returning HTTP responses. Change this to return entities from the services and the toResponse will be called in the controllers instead.
Also move exception mapping out of services.
Allow deletion of a book through REST call. Deletion is asynchronous.
DELETE
/book/{isbn}
200 if request is queued and 404 if book is not found by ISBN
When a book is queued for deletion, a field is set on the book for "pending deletion" and all copies are queue for deletion per #26
When the final copy of a book is marked as deleted, check the book status and set to deleted if pending deletion is the previous state.
Books in deleted state do not appear in search results.
Re-importing a previously deleted book with the same ISBN, will reset all fields on the pre-existing book to defaults.
When creating a book, add copies with a number of copies field.
Add a number of copies to add to the book request and return number of copies in the book response.
Improve error handling for:
Put genre creation in the same transaction as book creation.
We use string values for enums in database entities and these could be SQL enums instead. For example, copy availability. Convert strings to enums where applicable.
Request all loans for a user with filtering for active/inactive, sorted by most recent first.
For a library member, get all loans. Default filter is all loans, including those ended and in progress. Allow filtering of results to active and inactive. Include the loan start and end dates in the response. The end date is the checked in date for ended loans and expiry date for active loans. The end date will be updated in a later ticket for checking in.
If a member does not exist, return a 404. If a member does not have any loans, return empty results.
The results should have both the copy and the book information for each loan.
API must support pagination.
{
"paginationInfo": {"paginationInfo": "object"},
"loans": [
{"loanId": {"copyId": "", "book": {}, "startDate": "", "endDate: ""} }
]
}
When a user has a set of hold, allow them to view their holds.
GET
/member/{id}/holds
This will return the set of books they have a hold on and what number they are in line for a hold on that book. This does not need to be paginated as number of holds per user are limited.
Ensure decent code coverage with Jacoco.
We'd like to guarantee that a majority of our code has unit tests and that the unit tests cover a majority of cases. Full code coverage won't be attainable because of Jacoco Java/Kotlin interop.
Book create an import will duplicate genres and authors. We don't want duplicates.
When creating or importing an author or genre for a book, determine if duplicates exist and do not create new authors or genres if they do.
A genre is considered a duplicate if both have the same name (all lowercase).
An author is considered a duplicate if both have the same last and first name.
Add capability to check out a copy of a book to a library member.
/book/{isbn}/checkout
with a payload that has user ID and optionally a copy ID/book/{isbn}/checkout
{
"memberId" : "uuid",
"copyId":"uuid",
}
Response:
{
"loanId": "uuid",
"memberId": "uuid",
"copyId": "uuid",
"book": { "title": "", "author": "", "isbn": ""},
"loanStart": "date",
"loanEnd": "date",
}
Currently the app uses in memory H2 for a locally running database. Migrate the locally running service to use a postgres container for testing.
Create a docker-compose file to make it easy to run the service and the database at the same time. Also document/enable the use of queries to inspect the running database for testing.
Author names and book titles can contain any characters. Update to include only valid characters.
Author names can only have letters, spaces. I.e. "John A" or "Williams Jr" are allowed but not "Jim;K".
Book titles can include letters, spaces, and colons.
Remove trailing whitespace when importing or creating new Authors and Books.
Given a book has an image, request a particular image size either for thumbnail view to be used in search or detail view to be returned when get book is called.
Request a particular image size with a query parameter on a book image. When an image is uploaded, an AWS lambda should be used to automatically resize and store two copies of the image sized for detail and thumbnail views.
Return thumbnail on book search and detail on get book.
Implement external acceptance tests (i.e. not using @MicronautTest) to validate happy path cases for each feature.
Determine test framework to use (Java/gradle task, Karate test framework, etc.)
Test data will need to be created or verified to exist before the tests run (i.e. specific users, authors, books, etc.)
All basic happy path cases are covered against a running service.
/genres?pageNumber=5&sort=DESC
/genre/{id}
- pick oneResponse:
{
"name" : "Science Fiction",
"id": "<uuid>",
"ageGroup": "8-12"
}
#42 - tests need to be written related to this code
https://micronaut.io/blog/2021-03-09-micronaut-2-4-release.html
Authors and books in the application can be born/authored prior to January 1, 1970. Support authors and books with dates prior to that.
Disallow more than 10 copies of a book regardless of copy status.
Querying for books does not work for specific edge cases and this task is to fix those.
Cases where availability queries fail:
Get all loans by ISBN including user ID, active only.
Get all loans for a book that are currently active, sorted by soonest to expire first. Request/response is paginated.
Allow editing of existing books
Fields to edit:
Dockerize Library application for deployment.
Eventually we'll deploy to a container orchestration system.
Nothing yet
Add single image to book details.
Ability to add an image in the Book edit feature #14 , Book creation, and Book CSV import.
Images can be stored locally for local testing or in AWS S3. Whether to read from S3 will be determined through Micronaut profiles.
A default image is to be provided in the application if an image cannot be loaded from the provided location.
Image links should be present for getting books and searching books. Images are not needed (yet) for viewing loans or holds.
A valid image should have minimum and maximum size checked as well as file type verified. If an image fails the check on CSV import, ignore the image and continue with import. If verification fails on edit or create book, return a 400.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.