11import requests
22#from googlemaps import GooglePlaces, types, lang
33import json
4+ import pandas as pd
5+ import random
6+
7+ min_num = 0 # Minimum value of review id
8+ max_num = 50 # Maximum value of review id
9+ min_size = 0 # Minimum size of the amount of reviews
10+ max_size = 50 # Maximum size of the amount of reviews
11+ style_list = ['Pub' , 'Restaurant' , 'Bar' , 'Cafe' ]
412
513def load_env_variable (file_path , key ):
614 with open (file_path , "r" ) as f :
@@ -118,7 +126,52 @@ def convert_to_mongo_db_format():
118126 restaurants_for_mongo .append (restaurant_for_mongo )
119127 return restaurants_for_mongo
120128
129+ def generate_mock_restaurant_data ():
130+ mock_restaurants = []
131+ df = pd .read_csv ("backend/cmd/db/script/mock_restaurant_data.csv" )
132+ tags = {}
133+ tags ['servesBreakfast' ] = 'Serves Breakfast'
134+ tags ['servesLunch' ] = 'Serves Lunch'
135+ tags ['servesDinner' ] = 'Serves Dinner'
136+ tags ['servesBeer' ] = 'Serves Beer'
137+ tags ['servesWine' ] = 'Serves Wine'
138+ tags ['servesBrunch' ] = 'Serves Brunch'
139+ tags ['servesVegetarianFood' ] = 'Serves Vegetarian Food'
140+ tags ['servesCocktails' ] = 'Serves Cocktails'
141+ tags ['servesDessert' ] = 'Serves Dessert'
142+ tags ['servesCoffee' ] = 'Serves Coffee'
143+ available_tags = ['servesBreakfast' , 'servesLunch' , 'servesDinner' , 'servesBeer' , 'servesWine' , 'servesBrunch' , 'servesVegetarianFood' , 'servesCocktails' , 'servesDessert' , 'servesCoffee' ]
144+
145+ for index , row in df .iterrows ():
146+ mock_restaurants_for_mongo = {}
147+ mock_restaurants_for_mongo ['name' ] = row ['name' ]
148+ mock_restaurants_for_mongo ['address' ] = {}
149+ mock_restaurants_for_mongo ['address' ]['street' ] = row ['address.street' ]
150+ mock_restaurants_for_mongo ['address' ]['zipcode' ] = row ['address.zipcode' ]
151+ mock_restaurants_for_mongo ['address' ]['state' ] = row ['address.state' ]
152+ mock_restaurants_for_mongo ['address' ]['location' ] = {}
153+ mock_restaurants_for_mongo ['address' ]['location' ]['latitude' ] = row ['address.location.latitude' ]
154+ mock_restaurants_for_mongo ['address' ]['location' ]['longitude' ] = row ['address.location.longitude' ]
155+ list_size = random .randint (min_size , max_size )
156+ menu_list = list (set ([random .randint (min_num , max_num ) for _ in range (list_size )]))
157+ mock_restaurants_for_mongo ['menuItems' ] = menu_list
158+ mock_restaurants_for_mongo ['ratingAvg' ] = {}
159+ mock_restaurants_for_mongo ['ratingAvg' ]['overall' ] = row ['ratingAvg.overall' ]
160+ mock_restaurants_for_mongo ['ratingAvg' ]['return' ] = row ['ratingAvg.return' ]
161+ mock_restaurants_for_mongo ['style' ] = style_list [random .randint (0 , 3 )]
162+ mock_restaurants_for_mongo ['picture' ] = row ['picture' ]
163+ mock_restaurants_for_mongo ['restaurant' ] = row ['description' ]
164+ list_size = random .randint (0 , 9 )
165+ tags_idx_list = list (set ([random .randint (0 , 9 ) for _ in range (list_size )]))
166+ tag_list = []
167+ for idx in tags_idx_list :
168+ tag_list .append (available_tags [idx ])
169+ mock_restaurants_for_mongo ['tags' ] = []
170+ for tag in tag_list :
171+ mock_restaurants_for_mongo ['tags' ].append (tag )
172+ mock_restaurants .append (mock_restaurants_for_mongo )
173+ return mock_restaurants
174+
121175
122176#google_places_search()
123- #convert_to_mongo_db_format()
124-
177+ #convert_to_mongo_db_format()
0 commit comments