Esempio n. 1
0
def queue_counts(request):
    use_es = waffle.switch_is_active('reviewer-tools-elasticsearch')
    queues_helper = ReviewersQueuesHelper(use_es=use_es)

    counts = {
        'pending':
        queues_helper.get_pending_queue().count(),
        'rereview':
        queues_helper.get_rereview_queue().count(),
        'updates':
        queues_helper.get_updates_queue().count(),
        'escalated':
        queues_helper.get_escalated_queue().count(),
        'moderated':
        queues_helper.get_moderated_queue().count(),
        'region_cn':
        Webapp.objects.pending_in_region(mkt.regions.CN).count(),
        'additional_tarako':
        (AdditionalReview.objects.unreviewed(queue=QUEUE_TARAKO,
                                             and_approved=True).count()),
    }

    if 'pro' in request.GET:
        counts.update({'device': device_queue_search(request).count()})

    rv = {}
    if isinstance(type, basestring):
        return counts[type]
    for k, v in counts.items():
        if not isinstance(type, list) or k in type:
            rv[k] = v
    return rv
Esempio n. 2
0
def queue_counts(request):
    queues_helper = ReviewersQueuesHelper()

    counts = {
        'pending': queues_helper.get_pending_queue().count(),
        'rereview': queues_helper.get_rereview_queue().count(),
        'updates': queues_helper.get_updates_queue().count(),
        'escalated': queues_helper.get_escalated_queue().count(),
        'moderated': queues_helper.get_moderated_queue().count(),
        'region_cn': Webapp.objects.pending_in_region(mkt.regions.CN).count(),
        'additional_tarako': (
            AdditionalReview.objects
                            .unreviewed(queue=QUEUE_TARAKO, and_approved=True)
                            .count()),
    }

    if 'pro' in request.GET:
        counts.update({'device': device_queue_search(request).count()})

    rv = {}
    if isinstance(type, basestring):
        return counts[type]
    for k, v in counts.items():
        if not isinstance(type, list) or k in type:
            rv[k] = v
    return rv
Esempio n. 3
0
def queue_counts(request):
    use_es = waffle.switch_is_active('reviewer-tools-elasticsearch')
    queues_helper = ReviewersQueuesHelper(use_es=use_es)

    counts = {
        'pending': queues_helper.get_pending_queue().count(),
        'rereview': queues_helper.get_rereview_queue().count(),
        'updates': queues_helper.get_updates_queue().count(),
        'escalated': queues_helper.get_escalated_queue().count(),
        'moderated': queues_helper.get_moderated_queue().count(),
        'abuse': queues_helper.get_abuse_queue().count(),
        'abusewebsites': queues_helper.get_abuse_queue_websites().count(),
        'region_cn': Webapp.objects.pending_in_region(mkt.regions.CHN).count(),
        'additional_tarako': (
            AdditionalReview.objects
                            .unreviewed(queue=QUEUE_TARAKO, and_approved=True)
                            .count()),
    }

    rv = {}
    if isinstance(type, basestring):
        return counts[type]
    for k, v in counts.items():
        if not isinstance(type, list) or k in type:
            rv[k] = v
    return rv
Esempio n. 4
0
def queue_updates(request):
    queues_helper = ReviewersQueuesHelper(request)
    qs = queues_helper.get_updates_queue()
    apps = queues_helper.sort(qs, date_sort='nomination')
    apps = [QueuedApp(app, app.all_versions[0].nomination)
            for app in Webapp.version_and_file_transformer(apps)]

    return _queue(request, apps, 'updates', date_sort='nomination')
Esempio n. 5
0
def _progress():
    """Returns unreviewed apps progress.

    Return the number of apps still unreviewed for a given period of time and
    the percentage.
    """

    queues_helper = ReviewersQueuesHelper()

    base_filters = {
        'pending': (queues_helper.get_pending_queue(),
                    'nomination'),
        'homescreen': (queues_helper.get_homescreen_queue(),
                       'nomination'),
        'rereview': (queues_helper.get_rereview_queue(),
                     'created'),
        'escalated': (queues_helper.get_escalated_queue(),
                      'created'),
        'updates': (queues_helper.get_updates_queue(),
                    'nomination')
    }

    operators_and_values = {
        'new': ('gt', days_ago(5)),
        'med': ('range', (days_ago(10), days_ago(5))),
        'old': ('lt', days_ago(10)),
        'week': ('gte', days_ago(7))
    }

    types = base_filters.keys()
    progress = {}

    for t in types:
        tmp = {}
        base_query, field = base_filters[t]
        for k in operators_and_values.keys():
            operator, value = operators_and_values[k]
            filter_ = {}
            filter_['%s__%s' % (field, operator)] = value
            tmp[k] = base_query.filter(**filter_).count()
        progress[t] = tmp

    def pct(p, t):
        # Return the percent of (p)rogress out of (t)otal.
        return (p / float(t)) * 100 if p > 0 else 0

    percentage = {}
    for t in types:
        total = progress[t]['new'] + progress[t]['med'] + progress[t]['old']
        percentage[t] = {}
        for duration in ('new', 'med', 'old'):
            percentage[t][duration] = pct(progress[t][duration], total)

    return (progress, percentage)
Esempio n. 6
0
def _progress():
    """Returns unreviewed apps progress.

    Return the number of apps still unreviewed for a given period of time and
    the percentage.
    """

    queues_helper = ReviewersQueuesHelper()

    days_ago = lambda n: datetime.datetime.now() - datetime.timedelta(days=n)

    base_filters = {
        'pending': (queues_helper.get_pending_queue(),
                    'nomination'),
        'rereview': (queues_helper.get_rereview_queue(),
                     'created'),
        'escalated': (queues_helper.get_escalated_queue(),
                      'created'),
        'updates': (queues_helper.get_updates_queue(),
                    'nomination')
    }

    operators_and_values = {
        'new': ('gt', days_ago(5)),
        'med': ('range', (days_ago(10), days_ago(5))),
        'old': ('lt', days_ago(10)),
        'week': ('gte', days_ago(7))
    }

    types = base_filters.keys()
    progress = {}

    for t in types:
        tmp = {}
        base_query, field = base_filters[t]
        for k in operators_and_values.keys():
            operator, value = operators_and_values[k]
            filter_ = {}
            filter_['%s__%s' % (field, operator)] = value
            tmp[k] = base_query.filter(**filter_).count()
        progress[t] = tmp

    # Return the percent of (p)rogress out of (t)otal.
    pct = lambda p, t: (p / float(t)) * 100 if p > 0 else 0

    percentage = {}
    for t in types:
        total = progress[t]['new'] + progress[t]['med'] + progress[t]['old']
        percentage[t] = {}
        for duration in ('new', 'med', 'old'):
            percentage[t][duration] = pct(progress[t][duration], total)

    return (progress, percentage)
Esempio n. 7
0
def queue_updates(request):
    use_es = waffle.switch_is_active('reviewer-tools-elasticsearch')

    queues_helper = ReviewersQueuesHelper(request, use_es=use_es)
    apps = queues_helper.get_updates_queue()
    apps = queues_helper.sort(apps, date_sort='nomination')

    if not use_es:
        apps = [QueuedApp(app, app.all_versions[0].nomination)
                for app in Webapp.version_and_file_transformer(apps)]

    return _queue(request, apps, 'updates', date_sort='nomination',
                  use_es=use_es)
Esempio n. 8
0
def queue_updates(request):
    use_es = waffle.switch_is_active('reviewer-tools-elasticsearch')

    queues_helper = ReviewersQueuesHelper(request, use_es=use_es)
    apps = queues_helper.get_updates_queue()
    apps = queues_helper.sort(apps, date_sort='nomination')

    if use_es:
        apps = [QueuedApp(app, app.latest_version.nomination_date)
                for app in apps.execute()]
    else:
        apps = [QueuedApp(app, app.all_versions[0].nomination)
                for app in Webapp.version_and_file_transformer(apps)]

    return _queue(request, apps, 'updates', date_sort='nomination',
                  use_es=use_es)
Esempio n. 9
0
def queue_counts(request):
    use_es = waffle.switch_is_active('reviewer-tools-elasticsearch')
    queues_helper = ReviewersQueuesHelper(use_es=use_es)

    counts = {
        'pending': queues_helper.get_pending_queue().count(),
        'rereview': queues_helper.get_rereview_queue().count(),
        'updates': queues_helper.get_updates_queue().count(),
        'escalated': queues_helper.get_escalated_queue().count(),
        'moderated': queues_helper.get_moderated_queue().count(),
        'abuse': queues_helper.get_abuse_queue().count(),
        'abusewebsites': queues_helper.get_abuse_queue_websites().count(),
        'homescreen': queues_helper.get_homescreen_queue().count(),
    }

    rv = {}
    if isinstance(type, basestring):
        return counts[type]
    for k, v in counts.items():
        if not isinstance(type, list) or k in type:
            rv[k] = v
    return rv
Esempio n. 10
0
def queue_counts(request):
    use_es = waffle.switch_is_active('reviewer-tools-elasticsearch')
    queues_helper = ReviewersQueuesHelper(use_es=use_es)

    counts = {
        'pending': queues_helper.get_pending_queue().count(),
        'rereview': queues_helper.get_rereview_queue().count(),
        'updates': queues_helper.get_updates_queue().count(),
        'escalated': queues_helper.get_escalated_queue().count(),
        'moderated': queues_helper.get_moderated_queue().count(),
        'abuse': queues_helper.get_abuse_queue().count(),
        'abusewebsites': queues_helper.get_abuse_queue_websites().count(),
        'homescreen': queues_helper.get_homescreen_queue().count(),
    }

    rv = {}
    if isinstance(type, basestring):
        return counts[type]
    for k, v in counts.items():
        if not isinstance(type, list) or k in type:
            rv[k] = v
    return rv