compute_stats.py 433 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from datetime import timedelta

from stats_app.models import DailyConnections
from stats_app.utils import get_daily_connections, get_today_as_datetime


def update_daily_connections():
    yesterday = get_today_as_datetime() - timedelta(days=1)
    DailyConnections.objects.update_or_create(
        date=yesterday, defaults=dict(nb_connections=get_daily_connections())
    )


def update_all_stats():
    update_daily_connections()