Giter Club home page Giter Club logo

albendz-code-share's Introduction

About

This is a repo where @albendz pushes side projects or other code to share with people.

Lambda

So far this has a function called contactMe.py which is an AWS Lambda function to take a request from API Gateway, store the request in DynamoDB, and then send another SNS.

File Manager

A collection of examples for a data structures and algorithms presentation for PyLadies.

Women Who Code Connect NYC 2019

A presentation for a workshop showing how to extend mobile apps with serverless using Firebase Firestore.

Kotlin

Problems

A project to write and test interview practice problems.

Micronaut

A project to build a simple Kotlin Micronaut service

albendz-code-share's People

Contributors

albendz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mkelly1 sauravjha

albendz-code-share's Issues

Expand Book information

Summary

Add more details to books that are searchable

Details

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.

Acceptance Criteria

  • a library administrator can add tags to a book
  • users can search for books by tags
  • Add support for multiple genres for a book and search by multiple genres

Related

Update availability query on querying books to account for books with no copies

Summary

Querying for books does not work for specific edge cases and this task is to fix those.

Details

Cases where availability queries fail:

  • When there are no copies
  • The query selects for any copy in a particular state but "any copy in unavailable" does not mean the book is unavailable. Update or create a new query to change this to "all unavailable" vs. at least 1 unavailable.

Edit book through CSV import

Summary

When uploading CSV for books with already existing ISBN, update book information.

Details

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.

Related

#20

Add get genre API

Summary

  • Add API to get single genre
  • Add API to get all genres paginated

Details

  • GET /genres?pageNumber=5&sort=DESC
  • GET /genre/{id} - pick one
  • Return 404 when not found
  • Empty response when there are no genres

Response:

{
   "name" : "Science Fiction",
    "id": "<uuid>",
    "ageGroup": "8-12"
}

Related

#42 - tests need to be written related to this code

Dedup already existing authors and genres in book create and import

Summary

Book create an import will duplicate genres and authors. We don't want duplicates.

Details

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.

Allow users to place holds on an unavailable book

Summary

Allow users to place holds on a book

Details

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.

Add Detekt for Kotlin Code Quality Checks

Summary

We want code quality checks on each build.

Details

Use Detekt to set up code quality rules. Use defaults initially and customize later as needed.

Acceptance Criteria

  • When running build locally, it will fail when Detekt issues are detected

Related

NA

Edit book information through REST API

Summary

Support editing book information through REST API

Details

Create /book/{isbn} PUT operation to updated book information. Valid information that can be updated:

  • Title
  • Author
  • Publication date

No adjusting number of copies yet.

Related

Add number of copies when creating a book

Summary

When creating a book, add copies with a number of copies field.

Details

Add a number of copies to add to the book request and return number of copies in the book response.

Improve error handling for:

  • Author does not exist
  • Duplicate ISBN

Put genre creation in the same transaction as book creation.

Get loans for a member

Summary

Request all loans for a user with filtering for active/inactive, sorted by most recent first.

Details

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.

Acceptance Criteria

  • API to get loans by user: /member/{id}/loans?status={statusList}&pageNumber=x&itemsPerPage=y
    Response:
{
    "paginationInfo": {"paginationInfo": "object"},
    "loans": [
     {"loanId": {"copyId": "", "book": {}, "startDate": "", "endDate: ""}  }
    ]
}
  • Empty result set when member has no loans
  • 404 when member does not exist
  • 400 when invalid page number (< 0), invalid items Per Page (< 1), or invalid status

Related

#16

Convert all dates to all time compatible and sortable format

Summary

Authors and books in the application can be born/authored prior to January 1, 1970. Support authors and books with dates prior to that.

Acceptance Criteria

  • Authors can be added with DOB and DOD prior to Jan 1, 1970
  • Books can be added with publication dates prior to Jan 1, 1970
  • Search operations can sort books by publication date

Related

Move toResponse() to controller from services

Summary

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.

Enforce Genre name restrictions

Summary

Genre names can contain any characters. Update to restrict to only letters and spaces within the string.

Details

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.

Enforce Author and Book Title restrictions

Summary

Author names and book titles can contain any characters. Update to include only valid characters.

Details

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.

Library feature considerations

Summary

This ticket lists potential features that haven't been selected for development. All require further investigation.

Details

  • Zipkin tracing
  • Split into multiple services integrating with gRPC calls for internal communication
  • Metrics and monitoring with dashboard
  • kotlin-jpa
  • Micronaut Security

Limit number of copies per book to 10

Summary

Disallow more than 10 copies of a book regardless of copy status.

Details

  • Do not allow book add requests to create more than 10 copies
  • Do not allow csv import to create more than 10 copies
  • For editing or re-import, disallow more than 10 copies

Acceptance Criteria

  • Book request of greater than 10 copies defaults to 10
  • Maximum copies is configurable in application config
  • Duplicate book import will add copies but will not allow total copies per book to exceed 10 (or configured limit)
  • If configured limit is decreased then books with more than that new limit are left with that number of copies

Related

Get all active loans by ISBN

Summary

Get all loans by ISBN including user ID, active only.

Details

Get all loans for a book that are currently active, sorted by soonest to expire first. Request/response is paginated.

Related

#16

Delete copies of a book through REST API

Summary

Support deletion of a single copy of a book through a REST API

Details

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 more library member information and support editing

Summary

Add more user information to member details and support editing of editable fields.

Details

New user information:

  • Address
  • Phone number

Editable information:

  • Name
  • Address
  • Phone number

Uneditable information:

  • id
  • email

New information to be added to member responses

Related

Implement acceptance tests against running service

Summary

Implement external acceptance tests (i.e. not using @MicronautTest) to validate happy path cases for each feature.

Details

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.)

Acceptance Criteria

All basic happy path cases are covered against a running service.

Related

Allow editing of book information

Summary

Allow editing of existing books

Details

Fields to edit:

  • Title
  • Author
  • Genre (add multiple genres when #13 is complete)
  • Publication date
  • Additional copies

Acceptance Criteria

  • A library administrator can make a single request to update multiple book fields
  • A library administrator can update Title, Author, Genre, publication date in a single request
  • A library administrator can make a request to add a new copy to a book

Related

#13

Integrate with postgres for local testing

Summary

Currently the app uses in memory H2 for a locally running database. Migrate the locally running service to use a postgres container for testing.

Details

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.

Acceptance Criteria

  • Library service has two local development application profiles: in memory H2 and postgres
  • docker-compose file exists to spin up the application and database locally
  • dockerfile exists to run just the database locally (or instructions to use an existing container)
  • guide/enable UI or other DB tools to query postgres (could be intellij tools)

Related

Check out books to a member

Summary

Add capability to check out a copy of a book to a library member.

Details

  • Add a REST endpoint to checkout a book to a user: /book/{isbn}/checkout with a payload that has user ID and optionally a copy ID
  • Create a loan in DB linking member and copy of book
  • Book not found if book is not found
  • No copies available if no copies are available
  • Member not found if member is not found
  • Copy not available if specific copy is not available
  • Loan should have start date and expiry date
  • Duplicate checkout requests where a user already has a copy of a book does not checkout another copy, instead it will update the loan expiry date (i.e. renewal of loan)
  • Add configurable loan duration which is used in initial loan and when extending a loan
  • When a copy of a book is checked out, the number of available copies is updated in the book entity and shows when retrieved

Acceptance Criteria

  • API to checkout a book to a user exists: /book/{isbn}/checkout
    Request:
{
    "memberId" : "uuid",
    "copyId":"uuid",
}

Response:

{
    "loanId": "uuid",
    "memberId": "uuid",
    "copyId": "uuid",
    "book": { "title": "", "author": "", "isbn": ""},
    "loanStart":  "date",
    "loanEnd": "date",
}
  • Checkout request for a member that already has a copy of a book will update the loan end date
  • 404 if book is not found
  • 404 if member is not found
  • 404 if copy is not found
  • 400 if copy requested is unavailable
  • 400 if book requested has no available copies
  • Loan length is in configuration with a default of 15 days
  • Book checked out updates available copies and total copies to show loans

Related

#17

Dockerize Library Application

Summary

Dockerize Library application for deployment.

Details

Eventually we'll deploy to a container orchestration system.

Acceptance Criteria

  • A Dockerfile exists for the project
  • Application can be run as a docker container locally

Related

Nothing yet

Implement Micronaut test integration tests

Summary

Using tests run with @MicronautTest annotation and no mocking, test end to end scenarios for each feature.

Details

  • Add and get books from adding a single book or csv import
  • Query all books from csv import
  • Add and get an author
  • Create and get a member

Not a complete list, will need to consider all new implemented features until this is complete.

Get all copies of a book by ISBN

Summary

Get all copies of book by ISBN

Details

If a book has multiple copies, return a list with copy information about availability, identifiers, and metadata.

Acceptance Criteria

  • A user can get all copies of a book by ISBN: GET /book/{isbn}/copies
{
    "isbn": "<isbn>",
    "copies": [
         {
             "id": "<id>",
             "status": "<status>",
             "metadata": {}
         }
    ]
}
  • When a book is not found then return 404 for book not found
  • When there are no copies, return an empty response

Related

NA

Add images to book details

Summary

Add single image to book details.

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.

Related

#33

Enforce loan limit per user to 10 books

Summary

When a user requests checking out a book, disallow checkout if the book is available and the user has 10 books already checked out.

In the event of a hold triggering a checkout, ignore the hold and move to the next one in line. #25

Related

#16

Support image resizing to thumbnail view and book detail view

Summary

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.

Details

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.

Related

#32

Deletion of a book from REST API

Summary

Allow deletion of a book through REST call. Deletion is asynchronous.

Details

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.

Support users checking in a book and automatic check in when the book loan expires

Summary

Allow book loans to be checked in / returned in two ways:

  • through a REST API
  • automatic job to expire loans

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.

Related

#16
#24

Add Logging Configuration

Summary

Add logging and logging configuration. Consider exporting to a logging service.

Details

Acceptance Criteria

Related

Get all holds by user

Summary

When a user has a set of hold, allow them to view their holds.

Details

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.

Acceptance Criteria

Related

#24

Target 70% Jacoco Test Coverage

Summary

Ensure decent code coverage with Jacoco.

Details

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.

Acceptance Criteria

  • Jacoco is configured to run after unit tests
  • Jacoco has a failure on lower than 70% code coverage

Related

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.