summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-05-20 13:45:33 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-05-20 13:45:33 (GMT)
commit16b656e27364a1e5f3b5d8152d91d7c44baae381 (patch)
tree8a20f956c05e1ba0d1fdd64f8fd6cd41da0da946
parent1b945a4b88aaa38e2397bd5a04c0208ad56a4cf6 (diff)
downloadpublik-client-scripts-16b656e27364a1e5f3b5d8152d91d7c44baae381.zip
publik-client-scripts-16b656e27364a1e5f3b5d8152d91d7c44baae381.tar.gz
publik-client-scripts-16b656e27364a1e5f3b5d8152d91d7c44baae381.tar.bz2
strasbourg: add mini json with authentic statistics (#43152)
-rw-r--r--clients/strasbourg/authentic-mini-stats.py16
-rw-r--r--debian/publik-strasbourg-scripts.cron.hourly17
2 files changed, 29 insertions, 4 deletions
diff --git a/clients/strasbourg/authentic-mini-stats.py b/clients/strasbourg/authentic-mini-stats.py
new file mode 100644
index 0000000..fba1229
--- /dev/null
+++ b/clients/strasbourg/authentic-mini-stats.py
@@ -0,0 +1,16 @@
+import json
+
+from django.contrib.auth import get_user_model
+from authentic2_auth_fc.models import FcAccount
+
+User = get_user_model()
+
+stats = {
+ 'total': User.objects.all().count(),
+ 'logged-in': User.objects.filter(last_login__isnull=False).count(),
+ 'without-any-roles': User.objects.filter(roles__isnull=True).count(),
+ 'without-any-roles-logged-in': User.objects.filter(roles__isnull=True, last_login__isnull=False).count(),
+ 'franceconnect': FcAccount.objects.all().count(),
+}
+
+print(json.dump(stats, indent=2))
diff --git a/debian/publik-strasbourg-scripts.cron.hourly b/debian/publik-strasbourg-scripts.cron.hourly
index 05f858d..e261fe1 100644
--- a/debian/publik-strasbourg-scripts.cron.hourly
+++ b/debian/publik-strasbourg-scripts.cron.hourly
@@ -1,6 +1,15 @@
#! /bin/sh
-test -x /usr/bin/wcsctl || exit 0
-test -d /var/lib/wcs/*strasbourg* || exit 0
-cd /var/lib/wcs/
-sudo -u wcs /usr/bin/wcsctl runscript --vhost *strasbourg* /usr/lib/publik/clients/strasbourg/index-formdefs-in-elasticsearch.py
+if [ -d /var/lib/wcs/*strasbourg* ]
+then
+ cd /var/lib/wcs/
+ sudo -u wcs /usr/bin/wcsctl runscript --vhost *strasbourg* /usr/lib/publik/clients/strasbourg/index-formdefs-in-elasticsearch.py
+fi
+
+if [ -d /var/lib/authentic2-multitenant/tenants/*strasbourg*/static/ ]
+then
+ cd /var/lib/authentic2-multitenant/tenants/*strasbourg*/static/
+ touch stats.json
+ cd /var/lib/authentic2-multitenant/tenants/
+ authentic2-multitenant-manage tenant_command runscript /usr/lib/publik/clients/strasbourg/authentic-mini-stats.py -d *strasbourg* > /var/lib/authentic2-multitenant/tenants/*strasbourg*/static/stats.json
+fi