Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]:Creating new Compartment and Seats (Schema Change) #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

HARISH-1222
Copy link

@HARISH-1222 HARISH-1222 commented May 14, 2024

Hi @Mayank2808sharma I hope you are doing well

closes: #20

I completed the task

Schema Changes

  • I create two tables : Compartments and Seats
  • Train and Compartments (one to many)
  • Compartments and Seats (one to many)

Code Changes

  • create train

    • when the admin create the train schema they also need to give the compartments data
      Request :

      {
          "train_name":"Train_1",
          "source":"Chennai",
          "destination" : "Coimbatore",
          "compartments" : [{
                  "name":"T-1-C-1",
                  "total_seats":10
              },{
                  "name":"T-1-C-2",
                  "total_seats":5
              }]
      }

      Response :

      {
          "train_name":"Train_1",
          "source":"Chennai",
          "destination" : "Coimbatore",
          "compartments" : [{
                  "name":"T-1-C-1",
                  "total_seats":10
              },{
                  "name":"T-1-C-2",
                  "total_seats":5
              }]
      }
  • update train

    • Admin can able to add new compartments in for a train

      request :

        ```json
        {
        "additionalCompartments":[{
                "name":"T-1-C-3",
                "total_seats":10
            },{
                "name":"T-1-C-4",
                "total_seats":15
            }]
        }
        ```
      

      Response :

      {
          "message": "Train and compartments updated successfully.",
          "train": {
              "id": 1,
              "train_name": "train_1",
              "source": "chennai",
              "destination": "coimbatore",
              "createdAt": "2024-05-14T09:56:31.994Z",
              "updatedAt": "2024-05-14T09:56:31.994Z",
              "Compartments": [
                  {
                      "id": 1,
                      "compartment_name": "T-1-C-1",
                      "createdAt": "2024-05-14T09:56:31.999Z",
                      "updatedAt": "2024-05-14T09:56:31.999Z",
                      "TrainId": 1
                  },
                  {
                      "id": 2,
                      "compartment_name": "T-1-C-2",
                      "createdAt": "2024-05-14T09:56:32.000Z",
                      "updatedAt": "2024-05-14T09:56:32.000Z",
                      "TrainId": 1
                  },
                  {
                      "id": 3,
                      "compartment_name": "T-1-C-3",
                      "createdAt": "2024-05-14T09:58:16.161Z",
                      "updatedAt": "2024-05-14T09:58:16.161Z",
                      "TrainId": 1
                  },
                  {
                      "id": 4,
                      "compartment_name": "T-1-C-4",
                      "createdAt": "2024-05-14T09:58:16.161Z",
                      "updatedAt": "2024-05-14T09:58:16.161Z",
                      "TrainId": 1
                  }
              ]
          }
      }
  • Ticket Booking :

    • the use can book the ticket based on the compartment like how the real IRCTC is

    • And clear the edge case like

      • if the use book 5 ticke and the there is no seats in any compartment
      • And Built based on ACID Property

      Request :

          {
              "train_id":1,
              "no_of_seats":2
          }

      Response :

          {
              [
                  {
                      "status": "Booked",
                      "train_id": 1,
                      "train_name": "train_1",
                      "seat_id": 3,
                      "seat_no": "T-1-C-1_3"
                  },
                  {
                      "status": "Booked",
                      "train_id": 1,
                      "train_name": "train_1",
                      "seat_id": 4,
                      "seat_no": "T-1-C-1_4"
                  }
              ]
          }
    • If there is no Enough seats

      Request :

          {
              "train_id":1,
              "no_of_seats":50
          }

      Response :

      {
          "message": "Seat not available"
      }
  • Booked Ticket details :

    • User can get the ticket details as well as seat number base on the compartment

    Request :
    details?booking_id=17

    Response :

            {
                "bookingId": 17,
                "bookingTime": "2024-05-14T11:20:13.571Z",
                "trainName": "train_1",
                "source": "chennai",
                "destination": "coimbatore",
                "username": "harish_admin",
                "seatNos": [
                    "T-1-C-3_2",
                    "T-1-C-3_2"
                ]
            }

@HARISH-1222
Copy link
Author

Hi @Mayank2808sharma
it's seems like the conflict in package.json

it's because I use nodemon, and sequelize cli

so just ignore it 😃

@HARISH-1222 HARISH-1222 changed the title Dev/harish [FEAT]:Creating new Compartment and Seats (Schema Change) May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT]:Creating new Compartment and Seats (Schema Change)
1 participant