Exemplo n.º 1
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})
Exemplo n.º 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)})
Exemplo n.º 3
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))
Exemplo n.º 4
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))
Exemplo n.º 5
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))
Exemplo n.º 6
0
def _events_chart(from_date, to_date, event_ids):
    "Returns events charts for provided date range and event ids"

    data = EventLog.objects.all()\
            .filter(create_dt__gte=from_date)\
            .filter(create_dt__lte=to_date)\
            .filter(event_id__in=event_ids)\
            .extra(select={'day':'DATE(create_dt)'})\
            .values('day', 'event_id')\
            .annotate(count=Count('pk'))\
            .order_by('day', 'event_id')
    return day_bars(data, from_date.year, from_date.month, 100, event_colors)
Exemplo n.º 7
0
def _events_chart(from_date, to_date, event_ids):
    "Returns events charts for provided date range and event ids"

    data = EventLog.objects.all()\
            .filter(create_dt__gte=from_date)\
            .filter(create_dt__lte=to_date)\
            .filter(event_id__in=event_ids)\
            .extra(select={'day':'DATE(create_dt)'})\
            .values('day', 'event_id')\
            .annotate(count=Count('pk'))\
            .order_by('day', 'event_id')
    return day_bars(data, from_date.year, from_date.month, 100, event_colors)
Exemplo n.º 8
0
def _events_chart(from_date, to_date, event_ids):
    "Returns events charts for provided date range and event ids"

    data = (
        EventLog.objects.all()
        .filter(create_dt__gte=from_date)
        .filter(create_dt__lte=to_date)
        .filter(event_id__in=event_ids)
        .extra(select={"day": "DATE(create_dt)"})
        .values("day", "event_id")
        .annotate(count=Count("pk"))
        .order_by("day", "event_id")
    )
    return day_bars(data, from_date.year, from_date.month, 100, event_colors)