Returns list of recommended restaurants based on provided list of restaurant IDs.
Parameters
- ids: Compulsory. List of IDs (comma separated) to be used to generate recommendations.
- top: Default = 5. Returns this number of recommendations based on descending score.
- prices: Optional. Only recommends restaurants with these prices (comma separated, valid values: 1=$, 2=$$, 3=$$$, 4=$$$).
- zip_codes: Optional. Only recommends restaurants with these zip_codes (comma separated).
Output
- total: Total recommendations returned
- recommendations: List of recommendations with score ranging from 0 to 1 (higher the score, more relevant the recommendation).
- input_ids: Details associated with IDs provided
- rejected: Rejected IDs
Example
- http://:/api/v0.1/recommend?ids=1,4&top=2&price=2,3&zip_codes=012345,712345
{
"total": 2,
"recommendations": [
{ "id":"2", "name":"Chicken Rice", "price":"$$", "zip_code":"012345", "tags": ["restaurant"], "score":0.6435643 },
{ "id":"9", "name":"Bak Kut Teh", "price":"$$", "zip_code":"712345", "tags": ["restaurant"], "score":0.543154 }
],
"input_ids": [
{ "id":"1", "name":"Tze Char", "price":"$$", "zip_code":"543210", "tags": ["restaurant"] }
]
"rejected_ids": [
"4"
]
}
Same as GET method, but also assumes provided restaurant IDs are user's preference & stores them in database.
- Additional "user_id" parameter required.
- All other parameters & output same as GET.
Prerequisite
- Heroku account
- Install postgreSQL (to use "psql" in command line)
Steps
- Login to Heroku via web browser.
- Create new app from Heroku dashboard.
- Install Heroku Postgres add-on.
- On Heroku Postgres add-on page, click on "Settings" > "View Credentials"
- Declare local environment variable based on these credentials.
export DATABASE="<to be filled in>"
export DATABASE_HOST="<to be filled in>"
export DATABASE_PORT="<to be filled in>"
export DATABASE_USER="<to be filled in>"
export DATABASE_PASS="<to be filled in>"
export DATABASE_URL="postgresql://${DATABASE_USER}:${DATABASE_PASS}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE}"
- Connect to Heroku Postgres with following psql command
cd <project folder>
PGPASSWORD=$DATABASE_PASS psql -h $DATABASE_HOST -U $DATABASE_USER $DATABASE
- Execute following commands to create the required tables
\i postgres/create_restn.sql
\i postgres/create_restn_tags.sql
\i postgres/create_restn_user_rating.sql
- Confirm that tables have been created
\dt
Prerequisite
- Git
- Heroku CLI
- Created Heroku App & Heroku Postgres (instructions above)
Steps
- Login to Heroku via web browser.
- Click on created app on Heroku dashboard.
- Click on "Settings" > "Reveal Config Vars".
- Add the following configuration variable (there should be a DATABASE_URL variable already present).
KEY = APP_SETTINGS, VALUE = config.ProductionConfig
- Click on "Deploy" > "Deploy using Heroku Git" section.
- Following instructions to push codes to Heroku App.
Prerequisite
- Python >=3.6 ("python --version" to check)
Steps
- Change to project folder.
cd <project folder>
- Create python virtual environment.
python -m venv venv
- Activate virtual environment. "(venv)" will appear at command prompt if activated.
venv\Scripts\activate (for windows) OR venv/bin/activate (for mac)
- Install required python packages.
pip install -r requirements.txt
Prerequisite
- Setup of python virtual environment (instructions above)
- Created Heroku App & Heroku Postgres (instructions above)
Steps
- If not activated yet, activate virtual environment ("(venv)" will appear at command prompt if activated).
cd <project folder>
venv\Scripts\activate (for windows) OR venv/bin/activate (for mac)
- Add local environment variable.
export APP_SETTINGS="config.DevelopmentConfig"
- Run python script.
cd <project folder>
python run.py