/nearby, subscriptions check, geocoding #2
@ -392,7 +392,7 @@ class HoloUser():
|
|||||||
try:
|
try:
|
||||||
progress["application"][str(stage)] = find_location(query)
|
progress["application"][str(stage)] = find_location(query)
|
||||||
if ("lat" in progress["application"][str(stage)] and "lng" in progress["application"][str(stage)]):
|
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)]["lat"]
|
||||||
del progress["application"][str(stage)]["lng"]
|
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}})
|
col_tmp.update_one({"user": {"$eq": self.id}, "type": {"$eq": "application"}}, {"$set": {"application": progress["application"], "stage": progress["stage"]+1}})
|
||||||
|
@ -22,7 +22,7 @@ async def cmd_nearby(app: Client, msg: Message):
|
|||||||
if application is None:
|
if application is None:
|
||||||
await msg.reply_text(locale("nearby_user_empty", "message", locale=holo_user))
|
await msg.reply_text(locale("nearby_user_empty", "message", locale=holo_user))
|
||||||
return
|
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
|
else: # Find a place from input query
|
||||||
logWrite(f"Looking for the location by query '{' '.join(msg.command[1:])}'")
|
logWrite(f"Looking for the location by query '{' '.join(msg.command[1:])}'")
|
||||||
try:
|
try:
|
||||||
@ -37,8 +37,8 @@ async def cmd_nearby(app: Client, msg: Message):
|
|||||||
|
|
||||||
# Find all users registered in the area provided
|
# Find all users registered in the area provided
|
||||||
output = []
|
output = []
|
||||||
applications_nearby = col_applications.find( {"application.3.loc": { "$nearSphere": {"$geometry": {"type": "Point", "coordinates": [location[0], location[1]]}, "$maxDistance": configGet("search_radius")*1000} } } )
|
applications_nearby = col_applications.find( {"application.3.location": { "$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 }} } } } )
|
# {"application": {"3": {"location": {"$near": { "$geometry": { "type": "Point", "coordinates": location }, "$maxDistance": 30000 }} } } } )
|
||||||
|
|
||||||
for entry in applications_nearby:
|
for entry in applications_nearby:
|
||||||
if not entry["user"] == msg.from_user.id:
|
if not entry["user"] == msg.from_user.id:
|
||||||
|
@ -37,4 +37,4 @@ col_warnings = db.get_collection("warnings")
|
|||||||
col_applications = db.get_collection("applications")
|
col_applications = db.get_collection("applications")
|
||||||
col_sponsorships = db.get_collection("sponsorships")
|
col_sponsorships = db.get_collection("sponsorships")
|
||||||
|
|
||||||
col_applications.create_index([("application.3.loc", GEOSPHERE)])
|
col_applications.create_index([("application.3.location", GEOSPHERE)])
|
Reference in New Issue
Block a user