Restaurant
Service for all Recipe interactions
Main Module for the Restaurant-Search
Functions:
|
Add the given assessment to the Database. |
|
Apply all filter (current only Rating) |
|
Add a Filter to an existing person |
|
Delete one assessment that are mapped between the user and rest |
|
Search in the connected DB if one restaurant got already rated from the user and if so add the value to the restaurant |
|
Remove all Restaurants from the list under the given rating |
|
Get Bewertungen from a User to all restaurants |
|
Convert a string containing an address into coordinates |
|
Return the saved Filter from the Database if found one |
|
Do a full search for a Restaurant. |
|
Select one restaurant with specific weight. |
|
Update the comment and rating of a existing assessment |
|
Update a Filter from a User. |
- services.service_res.add_assessment(db_session: sqlalchemy.orm.session.Session, assessment: schemes.scheme_rest.RestBewertungCreate) schemes.scheme_rest.RestBewertungReturn [source]
Add the given assessment to the Database.
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the DB -> See db: Session = Depends(get_db)
assessment (schemes.scheme_rest.RestBewertungCreate) – The assessment need to be unique
- Raises
schemes.exceptions.DatabaseException – if the User or Restaurant does not exist or the assessment is duplicated
- Returns
The created Restaurant
- Return type
- services.service_res.apply_filter(rests: List[schemes.scheme_rest.Restaurant], user_f: schemes.scheme_filter.FilterRest) List[schemes.scheme_rest.Restaurant] [source]
Apply all filter (current only Rating)
- Parameters
rests (List[schemes.scheme_rest.Restaurant]) – List of all Restarants to apply the filter
filter (schemes.scheme_filter.FilterRest) – The Filter with all informations
- Returns
The filtered List of the restaurants
- Return type
- services.service_res.create_rest_filter(db_session: sqlalchemy.orm.session.Session, filter_rest: schemes.scheme_filter.FilterRestDatabase, user: schemes.scheme_user.UserBase) schemes.scheme_filter.FilterRestDatabase [source]
Add a Filter to an existing person
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the Database
filter_rest (schemes.scheme_filter.FilterRestDatabase) – Filter to add
user (schemes.scheme_user.UserBase) – Owner of the Filter
- Raises
schemes.exceptions.UserNotFound – If the User does not exist
- Returns
Added Filter
- Return type
- services.service_res.delete_assessment(db_session: sqlalchemy.orm.session.Session, user: schemes.scheme_user.UserBase, rest: schemes.scheme_rest.RestaurantBase) int [source]
Delete one assessment that are mapped between the user and rest
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the DB -> See db: Session = Depends(get_db)
user (schemes.scheme_user.UserBase) – The owner of the assessment
rest (schemes.scheme_rest.RestaurantBase) – The mapped Restaurant
- Raises
schemes.exceptions.DatabaseException – if the User or Restaurant does not exist
- Returns
The number of affected Rows of the delete
- Return type
int
- services.service_res.fill_user_rating(db_session: sqlalchemy.orm.session.Session, rests: List[schemes.scheme_rest.Restaurant], user: schemes.scheme_user.UserBase) List[schemes.scheme_rest.Restaurant] [source]
Search in the connected DB if one restaurant got already rated from the user and if so add the value to the restaurant
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the DB -> See db: Session = Depends(get_db)
google_res (List[schemes.scheme_rest.Restaurant]) – Restaurants for lookup
- Returns
Return of the input List with the user rating if one got found
- Return type
- services.service_res.filter_rating(rests: List[schemes.scheme_rest.Restaurant], rating: int) List[schemes.scheme_rest.Restaurant] [source]
Remove all Restaurants from the list under the given rating
- Parameters
rests (List[schemes.scheme_rest.Restaurant]) – List of all Restarants to filter
rating (int) – All under this number got removed
- Returns
Filtered List based ob the rating
- Return type
- services.service_res.get_assessments_from_user(db_session: sqlalchemy.orm.session.Session, user: schemes.scheme_user.UserBase) Optional[List[schemes.scheme_rest.RestBewertungReturn]] [source]
Get Bewertungen from a User to all restaurants
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the DB -> See db: Session = Depends(get_db)
user_mail (str) – Mail of the User
- Returns
Return a List of all Restaurants or None
- Return type
Union[List[schemes.scheme_rest.RestBewertungReturn], None]
- services.service_res.get_coordinates_from_location(location: str) schemes.scheme_rest.LocationBase [source]
Convert a string containing an address into coordinates
- Parameters
location (str) – The address/zipcode string to search
- Raises
NoneExcistingLocationException – Raises if the location was not found
- Returns
Location with the coordinates
- Return type
- services.service_res.get_rest_filter_from_user(db_session: sqlalchemy.orm.session.Session, user: schemes.scheme_user.UserBase) Optional[schemes.scheme_filter.FilterRestDatabase] [source]
Return the saved Filter from the Database if found one
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the Database
user (schemes.scheme_user.UserBase) – Owner of the filter
- Returns
Return the Filter or None
- Return type
Union[schemes.scheme_filter.FilterRest, None]
- services.service_res.search_for_restaurant(db_session: sqlalchemy.orm.session.Session, user: schemes.scheme_user.UserBase, user_f: schemes.scheme_filter.FilterRest) schemes.scheme_rest.Restaurant [source]
Do a full search for a Restaurant. This does the google search, weights the result with the user rating and choose one of the restaurants according to the weights
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the DB -> See db: Session = Depends(get_db)
user (schemes.scheme_user.UserBase) – User that contain the mail address
user_f (schemes.scheme_filter.FilterRest) – Filter that are needed for the search
- Raises
schemes.exceptions.NoResultsException – If no Results are found
schemes.exceptions.GoogleApiException – If no communication with the Google API are possible
- Returns
The one choosen Restaurant where the user have to go now!
- Return type
- services.service_res.select_restaurant(rests: List[schemes.scheme_rest.Restaurant]) schemes.scheme_rest.Restaurant [source]
Select one restaurant with specific weight. weight = user_rating * 4 + google_rating * 2. If None rating found it will be count as 0
- Parameters
user_res (List[schemes.scheme_rest.Restaurant]) – The Rating of the Restaurants are optional
- Returns
The random chooses restaurant
- Return type
- services.service_res.update_assessment(db_session: sqlalchemy.orm.session.Session, old_assessment: schemes.scheme_rest.RestBewertungCreate, new_assessment: schemes.scheme_rest.RestBewertungCreate) schemes.scheme_rest.RestBewertungReturn [source]
Update the comment and rating of a existing assessment
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the DB -> See db: Session = Depends(get_db)
old_assessment (schemes.scheme_rest.RestBewertungCreate) – The current assessment
new_assessment (schemes.scheme_rest.RestBewertungCreate) – The new assessment with the updated values
- Raises
schemes.exceptions.DatabaseException – if the User or Restaurant does not exist
- Returns
Restaurant with the new values
- Return type
- services.service_res.update_rest_filter(db_session: sqlalchemy.orm.session.Session, filter_updated: schemes.scheme_filter.FilterRestDatabase, user: schemes.scheme_user.UserBase) schemes.scheme_filter.FilterRestDatabase [source]
Update a Filter from a User. Need the full information of the filter (not only the new one)
- Parameters
db_session (sqlalchemy.orm.Session) – Session to the Database
filter_updated (schemes.scheme_filter.FilterRestDatabase) – The new Filter for the user
user (schemes.scheme_user.UserBase) – Owner of the Filter
- Raises
schemes.exceptions.UserNotFound – If the User is not in the db
- Returns
The updated Filter
- Return type