Beispiel #1
0
def users_added_report(request, kind):

    if kind == 'added':
        event_ids = (121000, 121100, 123001, 123103)
        title = _('Site Users Added Report')
    elif kind == 'referral':
        event_ids = (125114, 125115)
        title = _('Contacts Report - Referral Analysis Report (all contacts)')
    else:
        raise NotImplementedError('kind "%s" not supported' % kind)

    from_date, to_date = request_month_range(request)
    queryset = EventLog.objects.all()
    queryset = queryset.filter(create_dt__gte=from_date)
    queryset = queryset.filter(create_dt__lte=to_date)

    chart_data = _events_chart(from_date, to_date, event_ids)

    data = queryset.filter(event_id=221000)\
            .filter()\
            .values('headline')\
            .annotate(count=Count('pk'))\
            .order_by('-count')

    return render_to_response('reports/users_added.html',
                              {'data': data, 'chart_data': chart_data,
                               'report_title': title,
                               'entities': Entity.objects.all().order_by('entity_name'),
                               'site': Site.objects.get_current(),
                               'date_range': (from_date, to_date)},
                              context_instance=RequestContext(request))
Beispiel #2
0
def event_summary_historical_report(request):
    """
    This report queries based on source for historical reporting purposes
    """
    queryset = EventLog.objects.all()
    form = EventsFilterForm(request.GET)
    if form.is_valid():
        queryset = form.process_filter(queryset)

    from_date, to_date = request_month_range(request)
    next_day = to_date+timedelta(days=1)
    queryset = queryset.filter(create_dt__gte=from_date, create_dt__lte=next_day)

    chart_data = queryset\
                .extra(select={'day': 'DATE(create_dt)'})\
                .values('day', 'source')\
                .annotate(count=Count('pk'))\
                .order_by('day', '-count')
    chart_data = day_bars(chart_data, from_date.year, from_date.month, 300, source_colors)

    summary_data = queryset\
                .values('source')\
                .annotate(count=Count('pk'))\
                .order_by('-count')
    source_colors(summary_data)

    m = 1+len(summary_data)/3
    mm = 2*m
    summary_data = summary_data[:m], summary_data[m:mm], summary_data[mm:]

    return render_to_resp(
                request=request, template_name='reports/event_summary_historical.html',
                context={'chart_data': chart_data, 'summary_data': summary_data,
                 'form': form, 'date_range': (from_date, to_date)})
Beispiel #3
0
def event_source_summary_report(request, source):
    queryset = EventLog.objects.filter(source=source)
    form = EventsFilterForm(request.GET)
    if form.is_valid():
        queryset = form.process_filter(queryset)

    from_date, to_date = request_month_range(request)
    next_day = to_date+timedelta(days=1)
    queryset = queryset.filter(create_dt__gte=from_date, create_dt__lte=next_day)

    chart_data = queryset\
                .extra(select={'day': 'DATE(create_dt)'})\
                .values('day', 'event_id')\
                .annotate(count=Count('pk'))\
                .order_by('day', '-count')
    chart_data = day_bars(chart_data, from_date.year, from_date.month, 300, event_colors)

    summary_data = queryset\
                .values('event_id', 'description')\
                .annotate(count=Count('pk'))\
                .order_by('-count')
    event_colors(summary_data)

    return render_to_resp(
                request=request, template_name='reports/event_source_summary.html',
                context={'chart_data': chart_data, 'summary_data': summary_data,
                 'form': form, 'date_range': (from_date, to_date),
                 'source': source})
Beispiel #4
0
def users_added_report(request, kind):

    if kind == 'added':
        event_ids = (121000, 121100, 123001, 123103)
        title = _('Site Users Added Report')
    elif kind == 'referral':
        event_ids = (125114, 125115)
        title = _('Contacts Report - Referral Analysis Report (all contacts)')
    else:
        raise NotImplementedError('kind "%s" not supported' % kind)

    from_date, to_date = request_month_range(request)
    queryset = EventLog.objects.all()
    queryset = queryset.filter(create_dt__gte=from_date)
    queryset = queryset.filter(create_dt__lte=to_date)

    chart_data = _events_chart(from_date, to_date, event_ids)

    data = queryset.filter(event_id=221000)\
            .filter()\
            .values('headline')\
            .annotate(count=Count('pk'))\
            .order_by('-count')

    return render_to_response(
        'reports/users_added.html', {
            'data': data,
            'chart_data': chart_data,
            'report_title': title,
            'entities': Entity.objects.all().order_by('entity_name'),
            'site': Site.objects.get_current(),
            'date_range': (from_date, to_date)
        },
        context_instance=RequestContext(request))
Beispiel #5
0
def users_added_report(request, kind):

    if kind == "added":
        event_ids = (121000, 121100, 123001, 123103)
        title = _("Site Users Added Report")
    elif kind == "referral":
        event_ids = (125114, 125115)
        title = _("Contacts Report - Referral Analysis Report (all contacts)")
    else:
        raise NotImplementedError('kind "%s" not supported' % kind)

    from_date, to_date = request_month_range(request)
    queryset = EventLog.objects.all()
    queryset = queryset.filter(create_dt__gte=from_date)
    queryset = queryset.filter(create_dt__lte=to_date)

    chart_data = _events_chart(from_date, to_date, event_ids)

    data = queryset.filter(event_id=221000).filter().values("headline").annotate(count=Count("pk")).order_by("-count")

    return render_to_response(
        "reports/users_added.html",
        {
            "data": data,
            "chart_data": chart_data,
            "report_title": title,
            "entities": Entity.objects.all().order_by("entity_name"),
            "site": Site.objects.get_current(),
            "date_range": (from_date, to_date),
        },
        context_instance=RequestContext(request),
    )
Beispiel #6
0
def event_application_summary_report(request, application):
    queryset = EventLog.objects.filter(application=application)
    form = EventsFilterForm(request.GET)
    if form.is_valid():
        queryset = form.process_filter(queryset)

    from_date, to_date = request_month_range(request)
    next_day = to_date + timedelta(days=1)
    queryset = queryset.filter(create_dt__gte=from_date,
                               create_dt__lte=next_day)

    chart_data = queryset\
                .extra(select={'day': 'DATE(create_dt)'})\
                .values('day', 'action')\
                .annotate(count=Count('pk'))\
                .order_by('day', '-count')
    chart_data = day_bars(chart_data, from_date.year, from_date.month, 300,
                          action_colors)

    summary_data = queryset\
                .values('action', 'description')\
                .annotate(count=Count('pk'))\
                .order_by('-count')
    action_colors(summary_data)

    return render_to_response('reports/event_application_summary.html', {
        'chart_data': chart_data,
        'summary_data': summary_data,
        'form': form,
        'date_range': (from_date, to_date),
        'application': application
    },
                              context_instance=RequestContext(request))
Beispiel #7
0
def event_source_summary_report(request, source):
    queryset = EventLog.objects.filter(source=source)
    form = EventsFilterForm(request.GET)
    if form.is_valid():
        queryset = form.process_filter(queryset)

    from_date, to_date = request_month_range(request)
    next_day = to_date+timedelta(days=1)
    queryset = queryset.filter(create_dt__gte=from_date, create_dt__lte=next_day)

    chart_data = queryset\
                .extra(select={'day': 'DATE(create_dt)'})\
                .values('day', 'event_id')\
                .annotate(count=Count('pk'))\
                .order_by('day', '-count')
    chart_data = day_bars(chart_data, from_date.year, from_date.month, 300, event_colors)

    summary_data = queryset\
                .values('event_id', 'description')\
                .annotate(count=Count('pk'))\
                .order_by('-count')
    event_colors(summary_data)

    return render_to_response(
                'reports/event_source_summary.html',
                {'chart_data': chart_data, 'summary_data': summary_data,
                 'form': form, 'date_range': (from_date, to_date),
                 'source': source},
                context_instance=RequestContext(request))
Beispiel #8
0
def event_summary_historical_report(request):
    """
    This report queries based on source for historical reporting purposes
    """
    queryset = EventLog.objects.all()
    form = EventsFilterForm(request.GET)
    if form.is_valid():
        queryset = form.process_filter(queryset)

    from_date, to_date = request_month_range(request)
    next_day = to_date+timedelta(days=1)
    queryset = queryset.filter(create_dt__gte=from_date, create_dt__lte=next_day)

    chart_data = queryset\
                .extra(select={'day': 'DATE(create_dt)'})\
                .values('day', 'source')\
                .annotate(count=Count('pk'))\
                .order_by('day', '-count')
    chart_data = day_bars(chart_data, from_date.year, from_date.month, 300, source_colors)

    summary_data = queryset\
                .values('source')\
                .annotate(count=Count('pk'))\
                .order_by('-count')
    source_colors(summary_data)

    m = 1+len(summary_data)/3
    mm = 2*m
    summary_data = summary_data[:m], summary_data[m:mm], summary_data[mm:]

    return render_to_response(
                'reports/event_summary_historical.html',
                {'chart_data': chart_data, 'summary_data': summary_data,
                 'form': form, 'date_range': (from_date, to_date)},
                context_instance=RequestContext(request))