This is a very short guide on how it is possible to set up the ´dbSulten.db´ (Sulten database) on your computer:
- Download and install MariaDB on your computer
- Setup MariaDb by running:
sudo mysql_secure_installation
(set password to root) - Login to MariaDb:
sudo mariadb -u root -p
- Run script
create_dbSulten_scripts.sql
- Run script
queries.sql
- Run script
initialData.sql
- See bunch of rows being created.
- Exit.
- run
yarn
to install dependencies - start development server
yarn dev
The first thing you have to do is to populate the database with actual restaurant data (i.e menus). This is done by hitting the endpoint /admin/fetchMenusForAllAreas/:weekIndex
, example: http://localhost:8080/admin/fetchMenusForAllAreas/49.
Please be aware that SOME restaurants removes content successively during a week = the content changes.
By convention, the sulten logic is adapted to full menus. Most likely, the best time for fetching full menus is at mondays (it seems that most of the current menus are published by then).
- /admin/fetchMenusForAllAreas/:weekIndex
- /admin/fetchMenusForArea/:id
This is a very short guide on how it is possible to set up the ´dbSulten.db´ (Sulten database) on your computer:
- Download and install MariaDB on your computer
- Setup MariaDb by running:
sudo mysql_secure_installation
(set password to root) - Login to MariaDb:
sudo mariadb -u root -p
- Create a database
CREATE DATABASE dbSulten;
(obsolete: this is included increate_dbSulten_scripts.sql
) - Write
use sultenDb;
(obsolete: this is included increate_dbSulten_scripts.sql
) - Run
source /absolute/location/sulten/database/create_dbSulten_scripts.sql
- Run
source /absolute/location/sulten/database/queries.sql
- Run
source /absolute/location/sulten/database/initialData.sql
- See bunch of rows being created.
- Exit.
- run
yarn
to install dependencies - start development server
yarn dev
The first thing you have to do is to populate the database with actual restaurant data (i.e menus). This is done by hitting the endpoint /admin/fetchMenusForAllAreas/:weekIndex
, example: http://localhost:8080/admin/fetchMenusForAllAreas/49.
Please be aware that SOME restaurants removes content successively during a week = the content changes.
By convention, the sulten logic is adapted to full menus. Most likely, the best time for fetching full menus is at mondays (it seems that most of the current menus are published by then).
- /admin/fetchMenusForAllAreas/:weekIndex
- /admin/fetchMenusForArea/:id
http://localhost:8080/ or https://api.sulten.se
- /menu/allAreas
- /menu/mealsPerAreaWeekYear/:areaId/:weekNumber/:weekYear
- /menu/mealsPerAreaDayWeekYear/:areaId/:javaScriptDayIndex/:weekNumber/:weekYear
- /menu/restaurantsPerArea/:areaId
http://localhost:8080/menu/mealsPerAreaWeekYear/2/51/2019
[ { "restaurantName": "Restaurang Variation", "restaurantMenuUrl": "https://www.nyavariation.se/matsedel/", "alternativeLabelDishPrices": [ { "indexNumber": 1, "labelName": "meal_of_the_day", "dishDescription": "Helstekt fläskytterfilé med glöggkokta sviskon, gräddsås och kokt potatis", "dayIndex": 1, "priceSEK": "99.00" }, { "indexNumber": 2, "labelName": "meal_of_the_day", "dishDescription": "Husets paella serveras med vitlöksyoghurt", "dayIndex": 3, "priceSEK": "99.00" }, { "indexNumber": 1, "labelName": "salad", "dishDescription": "Potatis- och purjolökssoppa", "dayIndex": 3, "priceSEK": "75.00" }, ] }, ]
http://localhost:8080/menu/mealsPerAreaDayWeekYear/2/4/47/2019
[ { "dayIndex": 4, "restaurantName": "Lokal 17", "restaurantMenuUrl": "https://lokal17.se/", "alternativeLabelDishPrices": [ { "indexNumber": 1, "labelName": "meal_of_the_day", "dishDescription": "Gris-mandel-äpple-silverlök", "priceSEK": "123.00" }, { "indexNumber": 1, "labelName": "vegetarian", "dishDescription": "Jordärtsskocka-linser-tryffel-svamp", "priceSEK": "123.00" }, { "indexNumber": 1, "labelName": "dessert", "dishDescription": "En kula glass med salt kola & crisp", "priceSEK": "25.00" }, { "indexNumber": 2, "labelName": "dessert", "dishDescription": "Choklad tryffel", "priceSEK": "25.00" } ] }, { "dayIndex": 4, "restaurantName": "Restaurang Variation", "restaurantMenuUrl": "https://www.nyavariation.se/matsedel/", "alternativeLabelDishPrices": [ { "indexNumber": 1, "labelName": "meal_of_the_day", "dishDescription": "Pannbiff med lök, skysås, lingonsylt och kokt potatis", "priceSEK": "99.00" }, { "indexNumber": 2, "labelName": "meal_of_the_day", "dishDescription": "Ärtsoppa med fläskkorv och rökt fläsksida", "priceSEK": "99.00" }, { "indexNumber": 1, "labelName": "vegetarian", "dishDescription": "Bönbiffar serveras med vitlöksyoghurt", "priceSEK": "75.00" }, { "indexNumber": 1, "labelName": "salad", "dishDescription": "Potatis- och purjolökssoppa", "priceSEK": "75.00" } ] }, ]
http://localhost:8080/menu/allAreas
[ { "id": 3, "name": "Lund - Brunnshög" }, { "id": 4, "name": "Lund - Sjukhuset" }, { "id": 1, "name": "Malmö - Centrum" }, { "id": 2, "name": "Malmö - Västra Hamnen" } ]
https://api.sulten.se/menu/restaurantsPerArea/3
{ "area": { "id": 3, "name": "Lund - Brunnshög" }, "restaurants": [ { "id": 1, "active": true, "name": "Bricks Eatery", "menuUrl": "https://brickseatery.se/lunch/", "longitude": "55.71650200", "latitude": "13.22682000" } ] }
Dishes are categorized with different labels. Althought labels is text, some has been predefined in server/enum/LabelName.ts
as enums for simpler usage.
Here are some examples:
export enum LabelName { BARBACUE = "barbacue", DESSERT = "dessert", INDIAN = "indian", MEAL_OF_THE_DAY = "meal_of_the_day", PIZZA = "pizza", SOUP = "soup", THAI = "thai", VEGETARIAN = "vegetarian", }
- Add a new class to
src/server/admin/MealDealers
. The class should implementIWebMealDealerStatic
(it's suitable to copy another restaurants dealer class to use it as template). - The new restaurant dealer should be registered in
src/server/admin/MealDealers/DealerService.ts
(public allDealers(): IWebMealDealerStatic[] { ... }
). - The new restaurant has to be registered in
[dbSulten].[restaurants]
as well. - Update
./initialData.sql
with the new restaurant for future.