+
+
-
-
-
-
-
-
- {{ _("Downloads, past 7 days") }}
-
-
-
-
- ({{ _("%(downloads)s per day", downloads=("" | safe)) }})
-
-
-
-
-
-
-
-
-
-
-
- {{ _("Downloads, past 30 days") }}
-
-
-
-
- ({{ _("%(downloads)s per day", downloads=("" | safe)) }})
-
-
-
-
-
{{ _("Loading...") }}
@@ -106,7 +86,7 @@
{{ _("No data") }}
-
+
{{ _("Downloads by Package") }}
diff --git a/app/templates/packages/stats.html b/app/templates/packages/stats.html
index a5d3db84..5f0e945a 100644
--- a/app/templates/packages/stats.html
+++ b/app/templates/packages/stats.html
@@ -21,5 +21,5 @@
{{ render_package_selector(package.author, package=package) }}
{{ _("Statistics") }}
- {{ render_package_stats(package.getURL('api.package_stats', start=start, end=end), package.downloads) }}
+ {{ render_package_stats(package.getURL('api.package_stats', start=start, end=end), package.downloads, start or end) }}
{% endblock %}
diff --git a/app/templates/users/stats.html b/app/templates/users/stats.html
index b5e4119d..7f0d281f 100644
--- a/app/templates/users/stats.html
+++ b/app/templates/users/stats.html
@@ -17,5 +17,5 @@
{{ render_package_selector(user, package=None) }}
{{ self.title() }}
- {{ render_package_stats(url_for("api.user_stats", username=user.username, start=start, end=end), downloads) }}
+ {{ render_package_stats(url_for("api.user_stats", username=user.username, start=start, end=end), downloads, start or end) }}
{% endblock %}
diff --git a/app/utils/flask.py b/app/utils/flask.py
index 96ff818d..0a4a4bd9 100644
--- a/app/utils/flask.py
+++ b/app/utils/flask.py
@@ -38,13 +38,16 @@ def abs_url_for(endpoint: str, **kwargs):
scheme = "https" if app.config["BASE_URL"][:5] == "https" else "http"
return url_for(endpoint, _external=True, _scheme=scheme, **kwargs)
+
def abs_url(path):
return urljoin(app.config["BASE_URL"], path)
+
def abs_url_samesite(path):
base = urlparse(app.config["BASE_URL"])
return urlunparse(base._replace(path=path))
+
def url_current(abs=False):
if request.args is None or request.view_args is None:
return None
@@ -57,12 +60,25 @@ def url_current(abs=False):
else:
return url_for(request.endpoint, **dargs)
+
+def url_clear_query():
+ if request.endpoint is None:
+ return None
+
+ dargs = dict()
+ if request.view_args:
+ dargs.update(request.view_args)
+
+ return url_for(request.endpoint, **dargs)
+
+
def url_set_anchor(anchor):
args = MultiDict(request.args)
dargs = dict(args.lists())
dargs.update(request.view_args)
return url_for(request.endpoint, **dargs) + "#" + anchor
+
def url_set_query(**kwargs):
if request.endpoint is None:
return None
@@ -130,7 +146,7 @@ def get_daterange_options() -> List[Tuple[LazyString, str]]:
last_year_end = datetime.date(now.year - 1, 12, 31)
return [
- (lazy_gettext("All time"), url_set_query(start="2022-10-23", end=now.isoformat())),
+ (lazy_gettext("All time"), url_clear_query()),
(lazy_gettext("Last 7 days"), url_set_query(start=days7.isoformat(), end=now.isoformat())),
(lazy_gettext("Last 30 days"), url_set_query(start=days30.isoformat(), end=now.isoformat())),
(lazy_gettext("Last 90 days"), url_set_query(start=days90.isoformat(), end=now.isoformat())),