return res.count if res else 0
- def get_profile_histogram(self):
- today = datetime.date.today()
-
- t1 = datetime.date(year=today.year - 10, month=today.month, day=1)
- t2 = datetime.date(year=today.year, month=today.month, day=1)
-
- res = self.db.query("""
- SELECT
- date,
- COUNT(*) AS count
- FROM
- generate_series(%s, %s, INTERVAL '1 month') date
- JOIN
- fireinfo ON date >= created_at
- AND (expired_at IS NULL OR expired_at > date)
- GROUP BY
- date
- """, t1, t2)
-
- return { row.date : row.count for row in res }
-
# Profiles
def get_profile(self, profile_id, when=None):
</div>
</section>
{% end %}
-
- {% if histogram %}
- <section class="section">
- <div class="container">
- <table class="table">
- <tr>
- <th>{{ _("Date") }}</th>
- <th>{{ _("Total Profiles") }}</th>
- </tr>
-
- {% for date in sorted(histogram, reverse=True) %}
- <tr>
- <th scope="row">{{ format_date(date) }}</th>
- <td>
- {{ histogram[date] }}
- </td>
- </tr>
- {% end %}
- </table>
- </div>
- </section>
- {% end %}
{% end block %}
# Fetch the ASN map
asn_map = self.backend.fireinfo.get_asn_map()
- # Fetch the histogram
- histogram = self.backend.fireinfo.get_profile_histogram()
-
self.render("fireinfo/admin.html", with_data=with_data, total=total,
- asn_map=asn_map, histogram=histogram)
+ asn_map=asn_map)