Commit df78e1de authored by DmitSPopov's avatar DmitSPopov
Browse files

Add def for getting advantages in radius

parent 83c7ea13
......@@ -6,8 +6,23 @@ from web_setting import db
from models.all_models import ClickHistory
from collections import Counter
from api.api_advertisment import all_advertisments
from geopy.distance import geodesic
def get_adv_in_radius(user_location_str: str, radius: int):
user_location = user_location_str.split(', ')
user_location = (float(user_location[0]), float(user_location[1]))
all_adv = all_advertisments()
result_id = []
for _ in all_adv:
coords = _['connect_coordinates']['coordinates'].split(', ')
coords = (float(coords[0]), float(coords[1]))
if geodesic(user_location, coords).km <= radius:
result_id.append(_['id'])
return result_id
# print(get_adv_in_radius('55.53570015221644, 36.95149256704093', 1))
def calc_recomendation_by_tags(user_data, all_data):
row_column_index = []
for i in range(len(user_data)):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment