From 18e0cf19907d2f3dddd04ac50ac04b586c02e127 Mon Sep 17 00:00:00 2001 From: "matthias@arch" Date: Mon, 15 May 2023 23:56:49 +0200 Subject: [PATCH] Changed package structure --- .gitignore | 1 - regina/__init__.py | 6 ++---- regina/data_collection/__init__.py | 1 + .../package-data/_regina.compdef.zsh | 0 default.cfg => regina/package-data/default.cfg | 0 template.html => regina/package-data/template.html | 0 regina/sql/city_ranking.sql | 13 +++++++++++++ regina/sql/country.sql | 8 ++++++++ 8 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 regina/data_collection/__init__.py rename _regina.compdef.zsh => regina/package-data/_regina.compdef.zsh (100%) rename default.cfg => regina/package-data/default.cfg (100%) rename template.html => regina/package-data/template.html (100%) create mode 100644 regina/sql/city_ranking.sql create mode 100644 regina/sql/country.sql diff --git a/.gitignore b/.gitignore index 2076781..ca05787 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ test/ *__pycache__* build/ regina.egg-info/ -regina/test/ diff --git a/regina/__init__.py b/regina/__init__.py index 3fcf140..ff86da4 100644 --- a/regina/__init__.py +++ b/regina/__init__.py @@ -1,4 +1,2 @@ -"""Gather analytics from nginx access logs and visualize them through generated images and a generated html""" -# __package__ = 'regina' - -from regina import database +"""Gather analytics from nginx access logs and visualize them through generated plots and a generated html""" +from regina.database import Database diff --git a/regina/data_collection/__init__.py b/regina/data_collection/__init__.py new file mode 100644 index 0000000..77d3324 --- /dev/null +++ b/regina/data_collection/__init__.py @@ -0,0 +1 @@ +"""log parsing""" diff --git a/_regina.compdef.zsh b/regina/package-data/_regina.compdef.zsh similarity index 100% rename from _regina.compdef.zsh rename to regina/package-data/_regina.compdef.zsh diff --git a/default.cfg b/regina/package-data/default.cfg similarity index 100% rename from default.cfg rename to regina/package-data/default.cfg diff --git a/template.html b/regina/package-data/template.html similarity index 100% rename from template.html rename to regina/package-data/template.html diff --git a/regina/sql/city_ranking.sql b/regina/sql/city_ranking.sql new file mode 100644 index 0000000..23e9a0d --- /dev/null +++ b/regina/sql/city_ranking.sql @@ -0,0 +1,13 @@ +-- unused +SELECT ci.name,COUNT(v.visitor_id) +FROM city as ci, visitor as v, ip_range as i +WHERE ci.city_id = i.city_id +AND i.ip_range_id = v.ip_range_id +AND EXISTS( + SELECT 1 + FROM request AS r + WHERE r.visitor_id = v.visitor_id + AND r.time BETWEEN {timestamps[0]} AND {timestamps[1]} +) +GROUP BY ci.name +ORDER BY COUNT(v.visitor_id) diff --git a/regina/sql/country.sql b/regina/sql/country.sql new file mode 100644 index 0000000..f35356a --- /dev/null +++ b/regina/sql/country.sql @@ -0,0 +1,8 @@ +-- unused +SELECT co.name,COUNT(v.visitor_id) +FROM country as co, city as ci, visitor as v, ip_range as i +WHERE co.country_id = ci.country_id + AND ci.city_id = i.city_id + AND i.ip_range_id = v.ip_range_id +GROUP BY co.name +ORDER BY COUNT(v.visitor_id)