Compare commits

..

No commits in common. "38ad43af42d1937113360deffd1937dc95829385" and "953fc4afc88e1370e79fedcc6cd72872d1e720db" have entirely different histories.

3 changed files with 19 additions and 138 deletions

View File

@ -10,30 +10,20 @@ conn = sqlite3.connect(f'{selfpath}/../ipinfo.db')
c = conn.cursor()
# Detalle Visitas por pais
def vistas_pais_detalle(pais, codigo=''):
if codigo == '':
consulta = f"""
SELECT DATE(fecha, 'unixepoch') AS fecha_local, ip, metodo, cod_html, consulta
FROM visita WHERE ip IN (SELECT `ip` FROM `registro` WHERE `pais` = '{pais}');
"""
else:
consulta = f"""
SELECT DATE(fecha, 'unixepoch') AS fecha_local, ip, metodo, cod_html, consulta
FROM visita WHERE ip IN (SELECT `ip` FROM `registro` WHERE `pais` = '{pais}')
and cod_html = '{codigo}';
"""
def vistas_pais_detalle(pais):
pais = pais
consulta = f"""
SELECT DATE(fecha, 'unixepoch') AS fecha_local, ip, metodo, cod_html, consulta
FROM visita WHERE ip IN (SELECT `ip` FROM `registro` WHERE `pais` = '{pais}');
"""
c.execute(consulta)
resp = c.fetchall()
return resp
def pt_visita_pais_detalle(pais, codigo=''):
respuesta = vistas_pais_detalle(pais, codigo)
if codigo != '':
titulo = f"[bold][blue]Detalle visitas pais: [yellow]{pais}[blue] respuesta [/blue][yellow]{codigo}[/bold][yellow]"
else:
titulo = f"[bold][blue]Detalle visitas pais: [/blue][yellow]{pais}[/yellow][/bold]"
def pt_visita_pais_detalle(pais):
respuesta = vistas_pais_detalle(pais)
tbl_v = Table(
title=titulo,
title=f"[bold][blue]Detalle visitas pais: [/blue][yellow]{pais}[/yellow][/bold]",
box = box.ROUNDED,
show_lines = False,
row_styles=["dim", ""],

View File

@ -237,21 +237,14 @@ def main():
querys.pt_sel_pais_fecha(pais.upper(), fecha_unix, fecha_local)
case '--detalle-pais':
pais = sys.argv[3]
if len(sys.argv) > 4:
if sys.argv[4].isnumeric():
codigo = sys.argv[4]
querys.pt_visita_pais_detalle(pais.upper(), codigo)
else:
console.print(f'[magenta]-q --detalle-pais <pais> [/magenta][red][bold]<CODIGO> inválido ({sys.argv[4]})[/bold][/red]')
else:
querys.pt_visita_pais_detalle(pais.upper())
querys.pt_visita_pais_detalle(pais.upper())
case _:
console.print(f'[red] query desconocida [bold]{sys.argv[2]}[/bold][/red]')
case _:
ip = sys.argv[1]
print_ipinfo(ip, False)
except IndexError as ex:
console.print('[red] error sys.args! [/red]', ex)
except IndexError:
console.print('[red] error sys.args! [/red]')
finally:
sys.exit(0)
@ -270,16 +263,13 @@ def uso_consultas():
ayuda = f"""
[bold blue]ipLocate[/bold blue]
[deep_sky_blue1]Reportes según consultas a base de datos.
[deep_sky_blue1]Reportes según consultas a base de datos.[/deep_sky_blue1]
Uso: [deep_sky_blue1][bold][yellow]iploc -q[/yellow][blue] <consulta>[/bold][/blue]
[deep_sky_blue1]Consultas a base de datos:[deep_sky_blue1]
[bold yellow]-p[/bold yellow] [blue]<pais>[/blue] [green]- Conteo de respuestas html para <pais> (ejs. CL AR)[/green]
[bold yellow]--top [/bold yellow][blue]<n>[/blue] [green]- Visitas top <n> paises[/green]
[bold yellow]--pais-desde[/bold yellow][blue] <pais> <fecha>[/blue] [green]- Detalle visitas <pais> desde <fecha> (ej. 2022/9/19)[/green]
[bold yellow]--detalle-pais[/bold yellow][blue] <pais> opc(<cod>)[/blue] [green] - Muestra al detalle las visitas desde <pais>,
filtro por codigo opcional.[/green]
[bold blue]Consultas a base de datos:[/bold blue]
[bold yellow]iploc -q -p[/bold yellow] [blue]<pais>[/blue] [green]- Conteo de respuestas html para <pais> (ejs. CL AR)[/green]
[bold yellow]iploc -q --top [/bold yellow][blue]<n>[/blue] [green]- Visitas top <n> paises[/green]
[bold yellow]iploc -q --detalle-pais[/bold yellow][blue] <pais>[/blue] [green]- Muestra al detalle las visitas desde <pais>[/green]
[bold yellow]iploc -q --pais-desde[/bold yellow][blue] <pais> <fecha>[/blue] [green]- Detalle visitas <pais> desde <fecha> (ej. 2022/9/19)[/green]
"""
console.print(ayuda)
@ -289,7 +279,7 @@ def uso():
[deep_sky_blue1]Consulta en ipinfo.io (con o sin token) información sobre IP(s).
Carga logs de nginx en base de datos.
Consulta en ipinfo.io y registra en base de datos.
Consulta con ipinfo.io y registra en base de datos.
Consultas y reportes según información en la base de datos.[/deep_sky_blue1]
[bold yellow]iploc -h[/bold yellow] [green]- Muestra esta ayuda.[/green]

View File

@ -10899,96 +10899,6 @@
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 472.3255466666667 306.96768142637353 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 659.1796622222222 308.76501410984457 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 659.1796622222222 308.76501410984457 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 659.1796622222222 308.76501410984457 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 608.5667555555556 244.28931655227694 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 608.5667555555556 244.28931655227694 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 608.5667555555556 244.28931655227694 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 442.15793777777776 282.181571792469 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 442.15793777777776 282.181571792469 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 442.15793777777776 282.181571792469 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 217.08245333333332 322.2170022964495 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 217.08245333333332 322.2170022964495 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 217.08245333333332 322.2170022964495 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 490.2407111111112 291.5203559672854 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 490.2407111111112 291.5203559672854 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 490.2407111111112 291.5203559672854 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 426.15964444444444 274.5820322282227 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 426.15964444444444 274.5820322282227 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 426.15964444444444 274.5820322282227 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 237.67708444444452 301.73759730917715 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 237.67708444444452 301.73759730917715 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 237.67708444444452 301.73759730917715 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 279.8391466666667 488.5360122988299 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 279.8391466666667 488.5360122988299 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 279.8391466666667 488.5360122988299 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 210.51576888888894 449.42011650154853 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 210.51576888888894 449.42011650154853 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 210.51576888888894 449.42011650154853 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 734.1370311111111 450.8242408891255 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 734.1370311111111 450.8242408891255 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 734.1370311111111 450.8242408891255 l -3.4641016151377544 -6.0 a 4 4 0 1 1 6.928203230275509 0 Z" fill="#b20101" opacity="1.0" stroke="#ffffff" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 797.48224 326.9801587634675 l -4.330127018922193 -7.5 a 5 5 0 1 1 8.660254037844386 0 Z" fill="#00ff29" opacity="1.0" stroke="#000000" stroke-width="1"/>
</g>
@ -12726,15 +12636,6 @@
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 421.4705777777778 277.28170863802444 l -4.330127018922193 -7.5 a 5 5 0 1 1 8.660254037844386 0 Z" fill="#00ff29" opacity="1.0" stroke="#000000" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(-1024, 0)">
<path d="M 450.2512355555556 267.1300001806247 l -4.330127018922193 -7.5 a 5 5 0 1 1 8.660254037844386 0 Z" fill="#00ff29" opacity="1.0" stroke="#000000" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(0, 0)">
<path d="M 450.2512355555556 267.1300001806247 l -4.330127018922193 -7.5 a 5 5 0 1 1 8.660254037844386 0 Z" fill="#00ff29" opacity="1.0" stroke="#000000" stroke-width="1"/>
</g>
<g clip-path="url(#page)" transform="translate(1024, 0)">
<path d="M 450.2512355555556 267.1300001806247 l -4.330127018922193 -7.5 a 5 5 0 1 1 8.660254037844386 0 Z" fill="#00ff29" opacity="1.0" stroke="#000000" stroke-width="1"/>
</g>
<g clip-path="url(#page)">
<rect fill="#ffffff" fill-opacity="0.8" height="12" width="1024" x="0" y="756"/>
<text fill="#000000" font-family="Arial, Helvetica, sans-serif" font-size="9px" x="2" y="765">Maps &amp; Data (C) OpenStreetMap.org contributors</text>

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB