From 953fc4afc88e1370e79fedcc6cd72872d1e720db Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Tue, 20 Sep 2022 13:15:48 -0300 Subject: [PATCH] fix: -q --top --- README.md | 19 +++++++++++-------- consultas/querys_sqlite.py | 13 +++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7f5c3b5..d327bd0 100644 --- a/README.md +++ b/README.md @@ -191,13 +191,13 @@ ej. formato `./archivo_IPs`. **`iploc -q --top 3`** ```txt - Vistas Top 3 + Vistas Top 3 ╭──────┬─────────╮ │ País │ Visitas │ ├──────┼─────────┤ -│ US │ 2146 │ -│ CN │ 515 │ -│ DE │ 363 │ +│ US │ 11861 │ +│ RU │ 4727 │ +│ NL │ 4405 │ ╰──────┴─────────╯ ``` @@ -235,7 +235,9 @@ ej. formato `./archivo_IPs`. ╰────────────┴────────────────┴────────┴───────────┴──────────────────────╯ ``` -### Sicronización manual +---- + +## Sicronización manual No es necesario el uso manual del script, ya que este es llamado por `iploc --sync`. Pero ya que existe, puede resultar conveniente tener la opción de llamar manualmente a las funciones. @@ -264,8 +266,9 @@ Pero ya que existe, puede resultar conveniente tener la opción de llamar manual `./muevelog.sh --start`: Realiza todo el proceso **--sync**, **--copia**, **--extraer** y **--concat**. +---- -### Implementación +## Implementación Clonar proyecto en directorio ej. `~/nginx_data`. Crear `alias iploc='~/nginx_data/iplocate.py'`. @@ -301,9 +304,9 @@ Correr `iploc -h` para crear base de datos. ``` 📂️ nginx_data/ ├── 📁️ consultas/ -│ └──  querys_sqlite.py +│ └── 📄️ querys_sqlite.py ├── 📁️ maps -│ └── map_thumb.svg +│ └── 📄️ map_thumb.svg ├── 📄️ __init__.py ├── 📄️ config.cfg ├── 📄️ ipinfo.db diff --git a/consultas/querys_sqlite.py b/consultas/querys_sqlite.py index 88795d6..e931694 100755 --- a/consultas/querys_sqlite.py +++ b/consultas/querys_sqlite.py @@ -89,12 +89,13 @@ def pt_sel_pais_fecha(pais, fecha_ux, fecha_loc): # Top 50 paises def top_paises(top): consulta = f""" - SELECT pais, - count(pais) AS Ocurrencias - FROM registro - GROUP BY pais - ORDER BY count(*) DESC - LIMIT {top}; + SELECT registro.pais, + count(registro.pais) as Visitas + FROM visita, registro + WHERE visita.ip=registro.ip + GROUP BY pais + ORDER BY count(*) DESC + LIMIT {top}; """ c.execute(consulta) resp = c.fetchall()