parent 046b5bae
......@@ -30,7 +30,6 @@ id_points = [(4,), (905,), (11311,), (15515,)]
# Get digital city subnets
subnets = {}
pg_cur.execute("SELECT DISTINCT id_point FROM entity_net")
for point in pg_cur.fetchall():
subnet_query = "SELECT net FROM entity_net WHERE id_point = %d;" % point[0]
......@@ -97,16 +96,15 @@ while True:
collect_by = row['macaddr']
elif project == 'Cidades Digitais':
# Collect by subnet
ip_str = row['ip']
ip = IPNetwork(row['ip'])
try:
collect_by = str(net_cached[ip_str])
collect_by = str(net_cached[ip])
except:
for subnet in subnets[row['id_point']]:
if ip in subnet:
collect_by = str(subnet)
net_cached[ip_str] = subnet
net_cached[ip] = subnet
break
elif project == 'TLBR_GESAC':
# Collect by ip or macaddr
......
......@@ -68,7 +68,8 @@ def get_point_info(id_points, pipe):
WHERE
id_point = %s AND
contact_date >= \'%s\'
""") % (', '.join(attrs), id_point[0], base_date)
"""
) % (','.join(attrs), id_point[0], base_date)
points_cur.execute(query)
rows = points_cur.fetchmany(100000)
......
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