Пример #1
0
def escalate_questions():
    """Escalate questions needing attention.

    Escalate questions where the status is "needs attention" and
    still have no replies after 24 hours, but not that are older
    than 25 hours (this runs every hour).
    """
    if settings.STAGE:
        return
    # Get all the questions that need attention and haven't been escalated.
    qs = Question.objects.needs_attention().exclude(
        tags__slug__in=[config.ESCALATE_TAG_NAME])

    # Only include English.
    qs = qs.filter(locale=settings.WIKI_DEFAULT_LANGUAGE)

    # Exclude certain products.
    qs = qs.exclude(product__slug__in=config.ESCALATE_EXCLUDE_PRODUCTS)

    # Exclude those by inactive users.
    qs = qs.exclude(creator__is_active=False)

    # Filter them down to those that haven't been replied to and are over
    # 24 hours old but less than 25 hours old. We run this once an hour.
    start = datetime.now() - timedelta(hours=24)
    end = datetime.now() - timedelta(hours=25)
    qs_no_replies_yet = qs.filter(
        last_answer__isnull=True,
        created__lt=start,
        created__gt=end)

    for question in qs_no_replies_yet:
        escalate_question.delay(question.id)

    return len(qs_no_replies_yet)
Пример #2
0
def escalate_questions():
    """Escalate questions needing attention.

    Escalate questions where the status is "needs attention" and
    still have no replies after 24 hours, but not that are older
    than 25 hours (this runs every hour).
    """
    if settings.STAGE:
        return
    # Get all the questions that need attention and haven't been escalated.
    qs = Question.objects.needs_attention().exclude(
        tags__slug__in=[config.ESCALATE_TAG_NAME])

    # Exclude those by inactive users.
    qs = qs.exclude(creator__is_active=False)

    # Filter them down to those that haven't been replied to and are over
    # 24 hours old but less than 25 hours old. We run this once an hour.
    start = datetime.now() - timedelta(hours=24)
    end = datetime.now() - timedelta(hours=25)
    qs_no_replies_yet = qs.filter(last_answer__isnull=True,
                                  created__lt=start,
                                  created__gt=end)

    for question in qs_no_replies_yet:
        escalate_question.delay(question.id)

    return len(qs_no_replies_yet)
Пример #3
0
def escalate_questions():
    """Escalate questions needing attention.

    Escalate questions where the status is "needs attention" and
    still have no replies after 24 hours, but not that are older
    than 7 days. (to avoid the backfill from hell).
    """
    if settings.STAGE:
        return
    # Get all the questions that need attention and haven't been escalated.
    qs = Question.objects.needs_attention().exclude(
        tags__slug__in=[config.ESCALATE_TAG_NAME])

    # Exclude those by inactive users.
    qs = qs.exclude(creator__is_active=False)

    # Filter them down to those that haven't been replied to and are over
    # 24 hours old.
    start = datetime.now() - timedelta(hours=24)
    end = datetime.now() - timedelta(days=7)
    qs_no_replies_yet = qs.filter(
        last_answer__isnull=True,
        created__lt=start,
        created__gt=end)

    for question in qs_no_replies_yet:
        question.tags.add(config.ESCALATE_TAG_NAME)
        escalate_question.delay(question.id)

    return len(qs_no_replies_yet)
Пример #4
0
    def handle(self, **options):
        """
        Escalate questions where the status is "needs attention" and
        still have no replies after 24 hours, but not that are older
        than 25 hours (this runs every hour).
        """
        # Get all the questions that need attention and haven't been escalated.
        qs = Question.objects.needs_attention().exclude(
            tags__slug__in=[config.ESCALATE_TAG_NAME])

        # Only include English.
        qs = qs.filter(locale=settings.WIKI_DEFAULT_LANGUAGE)

        # Exclude certain products.
        qs = qs.exclude(product__slug__in=config.ESCALATE_EXCLUDE_PRODUCTS)

        # Exclude those by inactive users.
        qs = qs.exclude(creator__is_active=False)

        # Filter them down to those that haven't been replied to and are over
        # 24 hours old but less than 25 hours old. We run this once an hour.
        start = datetime.now() - timedelta(hours=24)
        end = datetime.now() - timedelta(hours=25)
        qs_no_replies_yet = qs.filter(last_answer__isnull=True,
                                      created__lt=start,
                                      created__gt=end)

        for question in qs_no_replies_yet:
            escalate_question.delay(question.id)

        return str(len(qs_no_replies_yet))
Пример #5
0
def _tag_added(sender, question_id, tag_name, **kwargs):
    """Signal handler for new tag on question."""
    if tag_name == config.ESCALATE_TAG_NAME:
        escalate_question.delay(question_id)
Пример #6
0
def _tag_added(sender, question_id, tag_name, **kwargs):
    """Signal handler for new tag on question."""
    if tag_name == config.ESCALATE_TAG_NAME:
        escalate_question.delay(question_id)