fix: query geolocalization pure SQL
deprecating ORM SQLalchemy
This commit is contained in:
parent
b58964d68f
commit
83f109ee60
@ -9,6 +9,21 @@ console = Console()
|
||||
conn = sqlite3.connect(f'{selfpath}/../ipinfo.db')
|
||||
c = conn.cursor()
|
||||
|
||||
# GeoLoc
|
||||
def get_geoloc(codigo):
|
||||
if codigo == 200:
|
||||
consulta = """
|
||||
SELECT DISTINCT geoloc FROM registro WHERE ip in ( SELECT `ip` from visita WHERE cod_html=='200');
|
||||
"""
|
||||
else:
|
||||
consulta = """
|
||||
SELECT DISTINCT geoloc FROM registro WHERE ip in ( SELECT `ip` from visita WHERE cod_html!='200');
|
||||
"""
|
||||
c.execute(consulta)
|
||||
resp = c.fetchall()
|
||||
return resp
|
||||
|
||||
|
||||
# Detalle Visitas por pais
|
||||
def vistas_pais_detalle(pais, codigo=''):
|
||||
if codigo == '':
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 260 KiB After Width: | Height: | Size: 263 KiB |
@ -41,6 +41,7 @@ def map300(geolocs):
|
||||
|
||||
|
||||
def maps_gen(locs_200, locs_300):
|
||||
maps_thumbs(locs_200, locs_300)
|
||||
map200(locs_200)
|
||||
map300(locs_300)
|
||||
for loc in locs_300:
|
||||
@ -73,7 +74,7 @@ def maps_thumbs(locs_200, locs_300):
|
||||
lon = float(loc[0].split(',')[1])
|
||||
demo300 = staticmaps.create_latlng(lat,lon)
|
||||
cntxtdemo.add_object(staticmaps.Marker(demo300, color=staticmaps.parse_color('#b20101'), size=4))
|
||||
|
||||
|
||||
for loc in locs_200:
|
||||
lat = float(loc[0].split(',')[0])
|
||||
lon = float(loc[0].split(',')[1])
|
||||
|
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
from consultas.querys_sqlite import get_geoloc
|
||||
from iplocate import re, requests, token, filtro_ip_propia, selfpath, parser, log_usage
|
||||
from json import loads
|
||||
from datetime import datetime
|
||||
@ -468,10 +469,8 @@ def mapsgen():
|
||||
Llama a función maps_gen con estas listas de valores como argumentos.
|
||||
"""
|
||||
try:
|
||||
stmn = session.query(Registro.geoloc.distinct()).join('visitas').where(Visita.cod_html==200)
|
||||
loc_200 = session.execute(stmn).all()
|
||||
stmn = session.query(Registro.geoloc.distinct()).join('visitas').where(Visita.cod_html!=200)
|
||||
loc_300 = session.execute(stmn).all()
|
||||
loc_200 = get_geoloc(200)
|
||||
loc_300 = get_geoloc(300)
|
||||
maps_gen(loc_200, loc_300)
|
||||
except Exception as ex:
|
||||
print('Exception mapsgen: ', ex)
|
||||
|
Loading…
Reference in New Issue
Block a user