{
"restaurant_id": json_obj,
"restaurant_id": json_obj
...
}
json_obj
{
"operation": "add/update", // only required when you are using update_resturant_info.json
"id": restaurant_id,
"name": restaurant_name, # is compusory field in case of "add" operation.
"timings": {
"lunch": time_obj,
"breakfast" : time_obj,
"dinner": time_obj
}
}
This is the base file for initalizing database with restaurant information for open hours. It has json for format:
{
"1": {
"id": 1,
"name": "1abc",
"timings": {
"breakfast": {
"start_time": 8,
"end_time": 11
},
"lunch": {
"start_time": 14,
"end_time": 18
},
"dinner": {
"start_time": 19,
"end_time": 22
}
}
},
"2": {
"id": 2,
"name": "2abc",
"timings": {
"breakfast": {
"start_time": 8,
"end_time": 12
},
"lunch": {
"start_time": 11,
"end_time": 18
},
"dinner": null
}
},..
}
This file is to be used for updating the timings of restaurants. Do not change the name of the file as it is written inside the code. There are two variations of json in this file:
"4": {
"operation": "add",
"id": 4,
"name": "4ghi",
"timings": {
"breakfast": null,
"dinner": {
"start_time": 15,
"end_time": 22
}
}
}
ii. Updating timings of existing restaurants: Only put timings for either lunch, breakfast or dinner (all are not compulsory)
"1": {
"operation": "update",
"id": 1,
"timings": {
"breakfast": {
"start_time": 8,
"end_time": 11
},
"lunch": {
"start_time": 14,
"end_time": 18
}
}
}
iii. Remove particular hours from timings. Put null
as value if you want to remove a particualar timings.
"2": {
"operation": "update",
"id": 2,
"timings": {
"breakfast": {
"start_time": 6,
"end_time": 8
},
"lunch": {
"start_time": 14,
"end_time": 16
},
"dinner": null
}
}
In the above example the timings for dinner will be removed from restaurants opening hours.
1. Clone this repository
2. Execute the file
>> python restaurant_listing.py
NOTE: There are prints of certain dictionary to verify output. (It can be ignored.)