Commit a465756f authored by Francesco Poldi's avatar Francesco Poldi

Fixed indexing

parent f89c8cca
...@@ -17,9 +17,7 @@ class RecycleObject(object): ...@@ -17,9 +17,7 @@ class RecycleObject(object):
def getLocation(place): def getLocation(place):
location = geolocator.geocode(place) location = geolocator.geocode(place)
if location: return {"lat": location.latitude, "lon": location.longitude}
return {"lat": location.latitude, "lon": location.longitude}
return {}
def handleIndexResponse(response): def handleIndexResponse(response):
try: try:
...@@ -182,8 +180,6 @@ def Tweet(Tweet, config): ...@@ -182,8 +180,6 @@ def Tweet(Tweet, config):
} }
day = weekdays[strftime("%A", localtime(Tweet.datetime))] day = weekdays[strftime("%A", localtime(Tweet.datetime))]
location = getLocation(config.Near)
actions = [] actions = []
dt = f"{Tweet.datestamp} {Tweet.timestamp}" dt = f"{Tweet.datestamp} {Tweet.timestamp}"
...@@ -226,10 +222,11 @@ def Tweet(Tweet, config): ...@@ -226,10 +222,11 @@ def Tweet(Tweet, config):
"quote_id_str": Tweet.quote_id_str, "quote_id_str": Tweet.quote_id_str,
"quote_url": Tweet.quote_url, "quote_url": Tweet.quote_url,
"search": str(config.Search), "search": str(config.Search),
"near": config.Near, "near": config.Near
"geo_tweet": location
} }
} }
if config.Near:
j_data["_source"].update({"geo_tweet": getLocation(config.Near)})
actions.append(j_data) actions.append(j_data)
es = Elasticsearch(config.Elasticsearch) es = Elasticsearch(config.Elasticsearch)
...@@ -266,8 +263,6 @@ def UserProfile(user, config): ...@@ -266,8 +263,6 @@ def UserProfile(user, config):
global _index_user_status global _index_user_status
actions = [] actions = []
location = getLocation(config.Location)
j_data = { j_data = {
"_index": config.Index_users, "_index": config.Index_users,
"_type": config.Index_type, "_type": config.Index_type,
...@@ -291,10 +286,11 @@ def UserProfile(user, config): ...@@ -291,10 +286,11 @@ def UserProfile(user, config):
"verified": user.is_verified, "verified": user.is_verified,
"avatar": user.avatar, "avatar": user.avatar,
"background_image": user.background_image, "background_image": user.background_image,
"session": config.Essid, "session": config.Essid
"geo_user": location
} }
} }
if config.Location:
j_data["_source"].update({"geo_user": getLocation(config.Location)})
actions.append(j_data) actions.append(j_data)
es = Elasticsearch(config.Elasticsearch) es = Elasticsearch(config.Elasticsearch)
......
Markdown is supported
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