if res:
return res.count
- def get_geo_location_map(self, when=None, minimum_percentage=1):
+ def get_geo_location_map(self, when=None, minimum_percentage=0):
res = self.db.query("WITH profiles AS (SELECT fireinfo_profiles_at(%s) AS id) \
SELECT location, COUNT(location)::float / (SELECT COUNT(*) FROM profiles) AS count FROM profiles \
LEFT JOIN fireinfo_profiles_locations ON profiles.id = fireinfo_profiles_locations.profile_id \
HAVING COUNT(location)::float / (SELECT COUNT(*) FROM profiles) >= %s ORDER BY count DESC",
when, minimum_percentage)
- return ((r.location, r.count) for r in res)
+ return list(((r.location, r.count) for r in res))
@property
def cpu_vendors(self):
</section>
<section>
+ <div class="container">
+ <div class="row">
+ <div class="col-12">
+ <h4>{{ _("Locations") }}</h4>
+
+ <dl class="row">
+ {% for country_code, percentage in locations %}
+ {% if percentage >= 0.01 %}
+ <dt class="col-sm-6">
+ <span class="flag-icon flag-icon-{{ country_code.lower() }} small mr-1"></span>
+ {{ format_country_name(country_code) }}
+ </dt>
+
+ <dd class="col-sm-6">
+ {% module ProgressBar(percentage, "success") %}
+ </dd>
+ {% end %}
+ {% end %}
+ </dl>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="col-12">
+ <small>
+ {{ _("IPFire is also running in these countries: %s") % locale.list(list((format_country_name(c) for c, p in locations if p < 0.01))) }}
+ </small>
+ </div>
+ </div>
+ </div>
+ </section>
+
+ <section class="inverse">
<div class="container">
<div class="row align-items-center">
<div class="col-12 col-md-6">
</div>
</section>
- <section class="inverse">
+ <section>
<div class="container">
<div class="row">
<div class="col-12 col-md-6 d-flex align-items-center text-md-right">
import tornado.web
import ipfire
+import ipfire.countries
from .handlers import *
# UI Modules
"ui_methods" : {
+ "format_country_name" : self.format_country_name,
"format_month_name" : self.format_month_name,
"format_phone_number" : self.format_phone_number,
"format_phone_number_to_e164" : self.format_phone_number_to_e164,
logging.info("Successfully initialied application")
+ def format_country_name(self, handler, country_code):
+ return ipfire.countries.get_name(country_code)
+
def format_month_name(self, handler, month):
_ = handler.locale.translate
# Virtualization
"hypervisors" : self.fireinfo.get_hypervisor_map(when=self.when),
"virtual_ratio" : self.fireinfo.get_virtual_ratio(when=self.when),
+
+ # Location
+ "locations" : self.fireinfo.get_geo_location_map(when=self.when),
}
# Cache for 1h