diff --git a/.vscode/settings.json b/.vscode/settings.json index 92010d599..1d088ac0c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -35,4 +35,6 @@ "files.associations": { "*.yml": "ansible" }, + "nrf-connect.toolchain.path": "${nrf-connect.toolchain:1.9.1}", + "C_Cpp.default.configurationProvider": "nrf-connect", } diff --git a/Maintenance.md b/Maintenance.md index 61ce1925c..5a21469d7 100644 --- a/Maintenance.md +++ b/Maintenance.md @@ -125,4 +125,18 @@ You got the downtime message either through email or SMS. This is the order of o crack are automatically fixed after 24 hours, but if many feeds fall through due to a bad deploy or electrical failure, you'll want to accelerate that check by just draining the tasked feeds pool, adding those feeds back into the queue. This command is idempotent. - \ No newline at end of file + +## Python 3 + +### Switching to a new redis server + +When the new redis server is connected to the primary redis server: + + # db-redis-story2 = moving to new server + # db-redis-story = old server about to be shutdown + make celery_stop + make maintenance_on + apd -l db-redis-story2 -t replicaofnoone + aps -l db-redis-story,db-redis-story2 -t consul + make maintenance_off + make task diff --git a/apps/monitor/views/newsblur_users.py b/apps/monitor/views/newsblur_users.py index 62421f5b3..fa106bdcd 100755 --- a/apps/monitor/views/newsblur_users.py +++ b/apps/monitor/views/newsblur_users.py @@ -5,6 +5,7 @@ from django.shortcuts import render from django.views import View from apps.profile.models import Profile, RNewUserQueue +from apps.statistics.models import MStatistics class Users(View): @@ -12,16 +13,33 @@ class Users(View): last_year = datetime.datetime.utcnow() - datetime.timedelta(days=365) last_month = datetime.datetime.utcnow() - datetime.timedelta(days=30) last_day = datetime.datetime.utcnow() - datetime.timedelta(minutes=60*24) - + expiration_sec = 60*60 # 1 hour + data = { - 'all': User.objects.count(), - 'yearly': Profile.objects.filter(last_seen_on__gte=last_year).count(), - 'monthly': Profile.objects.filter(last_seen_on__gte=last_month).count(), - 'daily': Profile.objects.filter(last_seen_on__gte=last_day).count(), - 'premium': Profile.objects.filter(is_premium=True).count(), - 'archive': Profile.objects.filter(is_archive=True).count(), - 'pro': Profile.objects.filter(is_pro=True).count(), - 'queued': RNewUserQueue.user_count(), + 'all': MStatistics.get('munin:users_yearly', + User.objects.count(), + set_default=True, expiration_sec=expiration_sec), + 'yearly': MStatistics.get('munin:users_yearly', + Profile.objects.filter(last_seen_on__gte=last_year).count(), + set_default=True, expiration_sec=expiration_sec), + 'monthly': MStatistics.get('munin:users_monthly', + Profile.objects.filter(last_seen_on__gte=last_month).count(), + set_default=True, expiration_sec=expiration_sec), + 'daily': MStatistics.get('munin:users_daily', + Profile.objects.filter(last_seen_on__gte=last_day).count(), + set_default=True, expiration_sec=expiration_sec), + 'premium': MStatistics.get('munin:users_premium', + Profile.objects.filter(is_premium=True).count(), + set_default=True, expiration_sec=expiration_sec), + 'archive': MStatistics.get('munin:users_archive', + Profile.objects.filter(is_archive=True).count(), + set_default=True, expiration_sec=expiration_sec), + 'pro': MStatistics.get('munin:users_pro', + Profile.objects.filter(is_pro=True).count(), + set_default=True, expiration_sec=expiration_sec), + 'queued': MStatistics.get('munin:users_queued', + RNewUserQueue.user_count(), + set_default=True, expiration_sec=expiration_sec), } chart_name = "users" chart_type = "counter" diff --git a/apps/statistics/models.py b/apps/statistics/models.py index c921e2940..ac1d64090 100644 --- a/apps/statistics/models.py +++ b/apps/statistics/models.py @@ -28,12 +28,16 @@ class MStatistics(mongo.Document): return "%s: %s" % (self.key, self.value) @classmethod - def get(cls, key, default=None): + def get(cls, key, default=None, set_default=False, expiration_sec=None): obj = cls.objects.filter(key=key).first() if not obj: + if set_default: + cls.set(key, default, expiration_sec=expiration_sec) return default if obj.expiration_date and obj.expiration_date < datetime.datetime.now(): obj.delete() + if set_default: + cls.set(key, default, expiration_sec=expiration_sec) return default return obj.value