Add stats for number of members older than six months
This commit is contained in:
parent
e8878fc02e
commit
4b74bc8ade
|
@ -9,13 +9,17 @@ class Command(BaseCommand):
|
|||
|
||||
def generate_stats(self):
|
||||
utils_stats.calc_next_events()
|
||||
member_count, green_count = utils_stats.calc_member_counts()
|
||||
member_count, green_count, six_month_plus_count = utils_stats.calc_member_counts()
|
||||
signup_count = utils_stats.calc_signup_counts()
|
||||
|
||||
# do this hourly in case an admin causes a change
|
||||
models.StatsMemberCount.objects.update_or_create(
|
||||
date=utils.today_alberta_tz(),
|
||||
defaults=dict(member_count=member_count, green_count=green_count),
|
||||
defaults=dict(
|
||||
member_count=member_count,
|
||||
green_count=green_count,
|
||||
six_month_plus_count=six_month_plus_count,
|
||||
),
|
||||
)
|
||||
|
||||
models.StatsSignupCount.objects.update_or_create(
|
||||
|
|
|
@ -142,6 +142,7 @@ class StatsMemberCount(models.Model):
|
|||
date = models.DateField(default=today_alberta_tz)
|
||||
member_count = models.IntegerField()
|
||||
green_count = models.IntegerField()
|
||||
six_month_plus_count = models.IntegerField()
|
||||
|
||||
class StatsSignupCount(models.Model):
|
||||
month = models.DateField()
|
||||
|
|
|
@ -2,7 +2,7 @@ import logging
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
import time
|
||||
from datetime import date, datetime
|
||||
from datetime import date, datetime, timedelta
|
||||
import requests
|
||||
from django.core.cache import cache
|
||||
from django.utils.timezone import now, pytz
|
||||
|
@ -64,11 +64,14 @@ def calc_member_counts():
|
|||
paused_count = members.count() - member_count
|
||||
green_count = num_current + num_prepaid
|
||||
|
||||
six_months_ago = today_alberta_tz() - timedelta(days=183)
|
||||
six_month_plus_count = not_paused.filter(application_date__lte=six_months_ago).count()
|
||||
|
||||
cache.set('member_count', member_count)
|
||||
cache.set('paused_count', paused_count)
|
||||
cache.set('green_count', green_count)
|
||||
|
||||
return member_count, green_count
|
||||
return member_count, green_count, six_month_plus_count
|
||||
|
||||
def calc_signup_counts():
|
||||
month_beginning = today_alberta_tz().replace(day=1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user