Changed "loc" to "location" in application

This commit is contained in:
Profitroll 2023-01-02 11:13:41 +01:00
parent ace71fd6be
commit 950666e4ad
3 changed files with 5 additions and 5 deletions

View File

@ -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}})

View File

@ -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:

View File

@ -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)])
col_applications.create_index([("application.3.location", GEOSPHERE)])