From 592d93c2a94ecd58316e673d2e3bf748958e086f Mon Sep 17 00:00:00 2001 From: "matthias@arch" Date: Mon, 28 Nov 2022 23:35:06 +0100 Subject: [PATCH] fixed referer ranking --- regina/__init__.py | 5 +---- regina/db_operation/visualize.py | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/regina/__init__.py b/regina/__init__.py index 611bd1e..0c15a23 100644 --- a/regina/__init__.py +++ b/regina/__init__.py @@ -1,7 +1,4 @@ """Gather analytics from nginx access logs and visualize them through generated images and a generated html""" # __package__ = 'regina' -# from db_operation import database, visualize, collect -import regina.db_operation -import regina.utility -print("running __init__.py") +from regina.db_operation import database, visualize, collect diff --git a/regina/db_operation/visualize.py b/regina/db_operation/visualize.py index 856306b..58a9156 100644 --- a/regina/db_operation/visualize.py +++ b/regina/db_operation/visualize.py @@ -321,9 +321,11 @@ def cleanup_referer(referer: str) -> str: domain = m.groups()[1].replace(subdomains, "") location = m.groups()[3] - assert(len(domain.split(".")) == 2) - referer = domain.split(".")[0] - if not settings["referer_ranking_ignore_tld"]: referer += "." + domain.split(".")[1] + if len(domain.split(".")) == 2: # if domain.tld + referer = domain.split(".")[0] + if not settings["referer_ranking_ignore_tld"]: referer += "." + domain.split(".")[1] + else: + referer = domain if not settings["referer_ranking_ignore_subdomain"]: referer = subdomains + referer if not settings["referer_ranking_ignore_subdomain"]: referer = subdomains + referer if not settings["referer_ranking_ignore_protocol"]: referer = protocol + "://" + referer