- Dependecies:
- PostgreSQL >= 9.3
- Ruby 2.7.1
- Yarn 1.22.4 (but it may work with other versions)
- Demo: Demo
NOTE: If you wish to setup the project with Docker, please check Docker usage section
- First, you need to have Postgres >= 9.3 installed and running. You can obtain more information about those steps here
- You also need to have Ruby 2.7.1 installed. You can accomplish this in many ways, but the most famous are: rbenv, rvm and asdf
- Yarn is also a requirement. You can install it checking the official documentation or using asdf
- Now, clone the project:
git clone https://github.com/jeduardo824/best_seats
- Open a Terminal window inside the folder that you downloaded the project.
- If you don't have
bundler
installed, please do withgem install bundler
. - If you don't have
foreman
installed, please do withgem install foreman
. - Run
bundle install
to install the necessary gems. - Run
yarn install
to install the necessary JS libraries. - After this, you can set up your local database with
bundle exec rails db:setup
. - You should be ready to run your local server with
foreman start -f Procfile.dev
.
- Clone the project:
git clone https://github.com/jeduardo824/best_seats
- Open a Terminal window inside the folder that you downloaded the project.
- You need to have Docker installed and running to use it.
- Run
./setup_dev
- When the process finishes,
docker-compose up
should work to have your local environment running.
- Problems with Database:
Inside
config
, check the filedatabase.yml
and ensure that configurations like host and port are accordingly with your Postgres - Problems with
./setup_dev
: Check if you have the permissions to run the script. You can do that withchmod +x setup_dev
- The application is also hosted in Heroku if you don't want to install it locally. You can access it on: https://best-seats-app.herokuapp.com/
You can run the tests with bundle exec rspec
. If you are using Docker, you should run docker-compose run --rm bundle exec rspec
.
Request: POST /api/v1/venues
Body:
{
"venue": {
"title": "My Title",
"rows": 10,
"columns": 50,
"available_seats": [
{
"row": "a",
"column": 1
},
{
"row": "b",
"column": 5
},
{
"row": "h",
"column": 7
}
]
}
}
Response:
{
"message": "Venue created successfully.",
"venue_id": 34
}
Status: 201
Request: GET /api/v1/venues/:venue_id/best_seats
Parameters:
seats_quantity
: Desired quantity of seats (Integer)group_seats
: If seats should be grouped or not (Boolean)
Ex: /api/v1/venues/34/best_seats?seats_quantity=2&group_seats=false
Response:
{
"success": "The best seats available are: [\"A1\", \"B5\"]",
"best_seats": [
{
"id": 216,
"row": 1,
"column": 1,
"label": "A1",
"venue_id": 34
},
{
"id": 217,
"row": 2,
"column": 5,
"label": "B5",
"venue_id": 34
}
]
}
Status: 200