<commit_before>import datetime

from huey.djhuey import crontab, db_periodic_task, db_task
from django.conf import settings
from django.contrib.auth import get_user_model

from main.models import Host
from stats.models import StatisticsEntry


@db_periodic_task(crontab(hour='0', minute='0'))
def save_user_count():
    count = get_user_model().objects.all().count()
    StatisticsEntry.objects.create(stat_type='user_count', value=count)


@db_periodic_task(crontab(hour='0', minute='0'))
def save_host_count():
    count = Host.objects.all().count()
    StatisticsEntry.objects.create(stat_type='host_count', value=count)

@db_task()
def increment_ip_update_count():
    today = datetime.date.today()
    (se, created) = StatisticsEntry.objects.get_or_create(
            stat_type='ip_update_count',
            created__year=(today.year),
            created__month=(today.month),
            created__day=(today.day),
            defaults={'value': 0}
    )
    se.value = se.value + 1
    se.save()
<commit_msg>fix timezone problem (hopefully)<commit_after>from datetime import datetime
import pytz

from huey.djhuey import crontab, db_periodic_task, db_task
from django.conf import settings
from django.contrib.auth import get_user_model

from main.models import Host
from stats.models import StatisticsEntry


@db_periodic_task(crontab(hour='0', minute='0'))
def save_user_count():
    count = get_user_model().objects.all().count()
    StatisticsEntry.objects.create(stat_type='user_count', value=count)


@db_periodic_task(crontab(hour='0', minute='0'))
def save_host_count():
    count = Host.objects.all().count()
    StatisticsEntry.objects.create(stat_type='host_count', value=count)

@db_task()
def increment_ip_update_count():
    today = datetime.now(pytz.utc)
    (se, created) = StatisticsEntry.objects.get_or_create(
            stat_type='ip_update_count',
            created__year=(today.year),
            created__month=(today.month),
            created__day=(today.day),
            defaults={'value': 0}
    )
    se.value = se.value + 1
    se.save()

{'fraction_non_alphanumeric': 0.12403846153846154, 'fraction_numerical': 0.0057692307692307696, 'mean_word_length': 4.255050505050505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2323929', 'n_tokens_mistral': 675, 'n_tokens_neox': 650, 'n_words': 123}