<commit_before># -*- coding: utf-8 -*-
from django.utils import timezone
from p2psafety.celery import app

from .models import Event, EventUpdate


@app.task
def eventupdate_watchdog(event_id,delay):
    """Task is run with
    eventupdate_watchdog.apply_async((event_id,delay),eta=now()+delay)
    and checks for new updates during the delay
    """
    event=Event.objects.get(id=event_id)
    if event.status == Event.STATUS_PASSIVE:
        time_pased = timezone.now() - event.latest_update.timestamp
        if time_pased > delay:
            #generate active eventupdate
            #which will trigger event to be active and show the reason
            EventUpdate(event=event,
                    active=True,
                    text="Watchdog alert. User was inactive for %s" %\
                            str(delay)
            ).save() #to call db hooks
        else:
            new_eta = event.latest_update.timestamp+delay
            eventupdate_watchdog.apply_async(
                    (event_id,delay),eta=new_eta)<commit_msg>ticket:87 Finishing with celery -> celery_app renaming<commit_after># -*- coding: utf-8 -*-
from django.utils import timezone
from p2psafety.celery_app import app

from .models import Event, EventUpdate


@app.task
def eventupdate_watchdog(event_id, delay):
    """Task is run with
    eventupdate_watchdog.apply_async((event_id,delay),eta=now()+delay)
    and checks for new updates during the delay
    """
    event = Event.objects.get(id=event_id)
    if event.status == Event.STATUS_PASSIVE:
        time_pased = timezone.now() - event.latest_update.timestamp
        if time_pased > delay:
            #generate active eventupdate
            #which will trigger event to be active and show the reason
            EventUpdate(event=event,
                    active=True,
                    text="Watchdog alert. User was inactive for %s" %\
                            str(delay)
            ).save()  # to call db hooks
        else:
            new_eta = event.latest_update.timestamp + delay
            eventupdate_watchdog.apply_async(
                (event_id, delay), eta=new_eta)
{'fraction_non_alphanumeric': 0.08823529411764706, 'fraction_numerical': 0.0028011204481792717, 'mean_word_length': 2.291858678955453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '500267', 'n_tokens_mistral': 605, 'n_tokens_neox': 587, 'n_words': 161}