diff --git a/classes/holo_user.py b/classes/holo_user.py index edf0a02..257e4ec 100644 --- a/classes/holo_user.py +++ b/classes/holo_user.py @@ -392,7 +392,7 @@ class HoloUser(): try: progress["application"][str(stage)] = find_location(query) if ("lat" in progress["application"][str(stage)] and "lng" in progress["application"][str(stage)]): - progress["application"][str(stage)]["loc"] = [float(progress["application"][str(stage)]["lng"]), float(progress["application"][str(stage)]["lat"])] + progress["application"][str(stage)]["location"] = [float(progress["application"][str(stage)]["lng"]), float(progress["application"][str(stage)]["lat"])] del progress["application"][str(stage)]["lat"] del progress["application"][str(stage)]["lng"] col_tmp.update_one({"user": {"$eq": self.id}, "type": {"$eq": "application"}}, {"$set": {"application": progress["application"], "stage": progress["stage"]+1}}) diff --git a/modules/commands/nearby.py b/modules/commands/nearby.py index f38334a..890a314 100644 --- a/modules/commands/nearby.py +++ b/modules/commands/nearby.py @@ -22,7 +22,7 @@ async def cmd_nearby(app: Client, msg: Message): if application is None: await msg.reply_text(locale("nearby_user_empty", "message", locale=holo_user)) return - location = application["application"]["3"]["loc"][0], application["application"]["3"]["loc"][1] + location = application["application"]["3"]["location"][0], application["application"]["3"]["location"][1] else: # Find a place from input query logWrite(f"Looking for the location by query '{' '.join(msg.command[1:])}'") try: @@ -37,8 +37,8 @@ async def cmd_nearby(app: Client, msg: Message): # Find all users registered in the area provided output = [] - applications_nearby = col_applications.find( {"application.3.loc": { "$nearSphere": {"$geometry": {"type": "Point", "coordinates": [location[0], location[1]]}, "$maxDistance": configGet("search_radius")*1000} } } ) - # {"application": {"3": {"loc": {"$near": { "$geometry": { "type": "Point", "coordinates": location }, "$maxDistance": 30000 }} } } } ) + applications_nearby = col_applications.find( {"application.3.location": { "$nearSphere": {"$geometry": {"type": "Point", "coordinates": [location[0], location[1]]}, "$maxDistance": configGet("search_radius")*1000} } } ) + # {"application": {"3": {"location": {"$near": { "$geometry": { "type": "Point", "coordinates": location }, "$maxDistance": 30000 }} } } } ) for entry in applications_nearby: if not entry["user"] == msg.from_user.id: diff --git a/modules/database.py b/modules/database.py index 8b038cb..9a4ba1d 100644 --- a/modules/database.py +++ b/modules/database.py @@ -37,4 +37,4 @@ col_warnings = db.get_collection("warnings") col_applications = db.get_collection("applications") col_sponsorships = db.get_collection("sponsorships") -col_applications.create_index([("application.3.loc", GEOSPHERE)]) \ No newline at end of file +col_applications.create_index([("application.3.location", GEOSPHERE)]) \ No newline at end of file