Add hourly task to count card scans
This commit is contained in:
parent
9b98ebf23a
commit
146d324025
|
@ -11,6 +11,7 @@ class Command(BaseCommand):
|
||||||
utils_stats.calc_next_events()
|
utils_stats.calc_next_events()
|
||||||
member_count, green_count = utils_stats.calc_member_counts()
|
member_count, green_count = utils_stats.calc_member_counts()
|
||||||
signup_count = utils_stats.calc_signup_counts()
|
signup_count = utils_stats.calc_signup_counts()
|
||||||
|
card_scans = utils_stats.calc_card_scans()
|
||||||
|
|
||||||
# do this hourly in case an admin causes a change
|
# do this hourly in case an admin causes a change
|
||||||
models.StatsMemberCount.objects.update_or_create(
|
models.StatsMemberCount.objects.update_or_create(
|
||||||
|
@ -23,6 +24,11 @@ class Command(BaseCommand):
|
||||||
defaults=dict(signup_count=signup_count),
|
defaults=dict(signup_count=signup_count),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
models.StatsSpaceActivity.objects.update_or_create(
|
||||||
|
date=utils.today_alberta_tz(),
|
||||||
|
defaults=dict(card_scans=card_scans),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
self.stdout.write('{} - Beginning hourly tasks'.format(str(now())))
|
self.stdout.write('{} - Beginning hourly tasks'.format(str(now())))
|
||||||
|
|
|
@ -111,3 +111,8 @@ def check_minecraft_server():
|
||||||
logger.error('Problem checking Minecraft: {} - {}'.format(e.__class__.__name__, str(e)))
|
logger.error('Problem checking Minecraft: {} - {}'.format(e.__class__.__name__, str(e)))
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def calc_card_scans():
|
||||||
|
date = today_alberta_tz()
|
||||||
|
cards = models.Card.objects
|
||||||
|
return cards.filter(last_seen_at=date).count()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user