Compare commits

..

2 Commits

Author SHA1 Message Date
83f109ee60 fix: query geolocalization pure SQL
deprecating ORM SQLalchemy
2023-06-06 04:48:14 -04:00
b58964d68f ed: sql_alch.py exception mapsgen prefix 2023-05-13 19:03:57 -04:00
5 changed files with 22 additions and 7 deletions

2
.gitignore vendored
View File

@ -8,5 +8,5 @@ maps/map_all.png
maps/map_all_dark.png
log/
*.db
config.cfg
config*.cfg
TODO

View File

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

View File

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

View File

@ -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: ', ex)
print('Exception mapsgen: ', ex)