From: Michael Tremer Date: Thu, 26 Apr 2018 18:23:12 +0000 (+0200) Subject: fireinfo: Show popular country on index page X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e400e37d7af60ebc45;p=ipfire.org.git fireinfo: Show popular country on index page Signed-off-by: Michael Tremer --- diff --git a/templates/index.html b/templates/index.html index 61aab0a9..3e33db01 100644 --- a/templates/index.html +++ b/templates/index.html @@ -174,7 +174,7 @@

FireInfo Statistics

-
+

Latest Release

{{ latest_release.name }}
@@ -185,39 +185,21 @@ $('.r_circle').circleProgress({ value: {{ latest_release.penetration }}, size: 128, thickness: 4, animation: false, startAngle: -Math.PI / 2, fill: { color: ["#1976d2"] } });
- -
-

Favorite Kernel

-
3.14.79-ipfire-pae
-
-

36%

-
- -
- -
-

Favorite CPU

-
Intel
-
-

73%

-
- -
- -
-

Favorite Virtualisation

-
VMWare
-
-

46%

-
- -
+ + {% if fireinfo_country %} +
+

+ {{ _("%.0f%% of all IPFire systems are running in") % (fireinfo_country.percentage * 100) }} +

+
{{ fireinfo_country.country.name }}
+
+

{{ "%.0f%%" % (fireinfo_country.percentage * 100) }}

+
+ +
+ {% end %}
diff --git a/webapp/backend/fireinfo.py b/webapp/backend/fireinfo.py index dff7e75c..bff06689 100644 --- a/webapp/backend/fireinfo.py +++ b/webapp/backend/fireinfo.py @@ -4,9 +4,11 @@ from __future__ import division import datetime import hwdata +import iso3166 import logging import re +import database import util from misc import Object @@ -1693,6 +1695,16 @@ class Fireinfo(Object): if res: return res.penetration + def get_random_country_penetration(self): + res = self.db.get("SELECT * FROM fireinfo_country_percentages \ + ORDER BY RANDOM() LIMIT 1") + + if res: + return database.Row({ + "country" : iso3166.countries.get(res.location), + "percentage" : res.count, + }) + # Hypervisor def create_hypervisor(self, hypervisor): diff --git a/webapp/handlers.py b/webapp/handlers.py index e8679f23..bfadf619 100644 --- a/webapp/handlers.py +++ b/webapp/handlers.py @@ -54,7 +54,8 @@ class IndexHandler(BaseHandler): latest_news = self.get_latest_news() return self.render("index.html", latest_news=latest_news, - latest_release=latest_release) + latest_release=latest_release, + fireinfo_country=self.fireinfo.get_random_country_penetration()) def get_latest_news(self, count=5): latest_news = []