Giter VIP home page Giter VIP logo

filmmanager's Introduction

The structure of this repository is the following:

  • "JSON Schemas" contains the design of the JSON Schemas;
  • "REST APIs Design" contains the full Open API documentation of the REST APIs, including examples of JSON documents to be used when invoking the operations, and examples of invocations of the API operations, possibly as a Postman collection;
  • "REST APIs Implementation" contains the code of the Film Manager service application.

How to run the code

  • The database is located inside the folder "REST APIs Implementation"/database
  • Run with command "npm start" inside the "REST APIs Implementation" folder
  • To test the APIs it is possible to use the postman collection inside the "REST APIs Design" folder

Design choices

  1. In order to allow the partial modification of a review, I updated the "updateSingleReview" function. Before allowing the update of the "completed" property, the function checks if all the review properties (reviewDate, rating, review) have been setted.

  2. In order to allow the delegation of a review, I started by updating the database "reviews" table by adding two new columns called "delegateId" and "delegated". The "delegated" column is set to 1 (True) if the row is a delegated review. The "delegateId" is the ID of the user who received the delegation. The "delegateId", together with the "filmId" and the "reviewerId" are the primary key.

Since there are no constraints about it, I decided to allow an user to write more than 1 review for the same Film. This means for example, if user A and B are issued for the review of Film F1, and B decides to delegate the review of Film F1 to A, this is allowed.
  1. Every time a user decides to delegate a review, after the proper checks, a new row is created in the "reviews" table. This new row has as the same fields (filmId, reviewerId, reviewDate, rating, review) of the original review. The "delegateId" of the new row gets setted to the ID of the delegated user and also the "delegated" field gets setted to 1 (True). After the insert, the "delegated" field of the original review is setted it to 1 (True).
Example:
User 1 wants to delegate review of Film 1 to User 2

filmId  reviewerId  delegateId  delegated   other-fields
  1        1           1           1            //
  1        1           2           1            //
  1. Starting from this point, the only user allowed to update the review is the delegated user. After an update, the row associated to the delegated review is updated, but the original one is not modified. In this way the original review is stored in case the delegator of the review decides to delete the delegation and return to the original review.

  2. When a delegation is deleted, after the proper checks, the delegated review is deleted from the database and the "delegated" field of the original review is setted it to 1 (False).

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.