diff --git a/mapadroid/db/DbStatsReader.py b/mapadroid/db/DbStatsReader.py
index 6f157142e..fb41d843f 100644
--- a/mapadroid/db/DbStatsReader.py
+++ b/mapadroid/db/DbStatsReader.py
@@ -370,3 +370,18 @@ def get_all_spawnpoints_count(self):
)
count = self._db_exec.autofetch_value(query)
return count
+
+ def get_noniv_encounters_count(self, minutes=240):
+ logger.info("Fetching get_noniv_encounters_count")
+ logger.debug3("Fetching get_noniv_encounters_count from db")
+ query_where = 'last_modified > \'%s\' ' % str(datetime.utcnow() - timedelta(minutes=int(minutes)))
+
+ query = (
+ "SELECT count(1) as Count, latitude, longitude "
+ "FROM pokemon "
+ "WHERE cp IS NULL AND %s "
+ "GROUP BY latitude, longitude" % (query_where)
+ )
+ res = self._db_exec.execute(query)
+ logger.info("Done fetching get_noniv_encounters_count")
+ return res
diff --git a/mapadroid/madmin/routes/statistics.py b/mapadroid/madmin/routes/statistics.py
index 064d2fc99..6fae256aa 100644
--- a/mapadroid/madmin/routes/statistics.py
+++ b/mapadroid/madmin/routes/statistics.py
@@ -55,6 +55,7 @@ def add_route(self):
("/reset_status_entry", self.reset_status_entry),
("/get_stop_quest_stats", self.get_stop_quest_stats),
("/statistics_stop_quest", self.statistics_stop_quest),
+ ("/get_noniv_encounters_count", self.get_noniv_encounters_count),
]
for route, view_func in routes:
self._app.route(route)(view_func)
@@ -792,3 +793,11 @@ def get_spawnpoints_stats_summary(self):
spawnpoints_total = self._db_stats_reader.get_all_spawnpoints_count()
stats = {'fences': possible_fences, 'events': events, 'spawnpoints_count': spawnpoints_total}
return jsonify(stats)
+
+ @logger.catch()
+ @auth_required
+ def get_noniv_encounters_count(self):
+ minutes_spawn = request.args.get('minutes_spawn', 240)
+ data = self._db_stats_reader.get_noniv_encounters_count(minutes_spawn)
+ stats = {'data': data}
+ return jsonify(stats)
diff --git a/static/madmin/templates/statistics/mon_statistics.html b/static/madmin/templates/statistics/mon_statistics.html
index 95130cdb8..60a67ae87 100644
--- a/static/madmin/templates/statistics/mon_statistics.html
+++ b/static/madmin/templates/statistics/mon_statistics.html
@@ -1,6 +1,8 @@
{% extends "base.html" %}
{% block header %}
+
+
{% endblock %}
{% block scripts %}
@@ -15,8 +17,17 @@
+
+
+