Example #1
0
File: api.py Project: nkabir/sentry
def poll(request, project):
    from sentry.templatetags.sentry_plugins import handle_before_events

    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    view_id = request.GET.get("view_id")
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    response = _get_group_list(request=request, project=project, view=view)

    event_list = response["event_list"]
    event_list = list(event_list[offset:limit])
    handle_before_events(request, event_list)

    data = transform_groups(request, event_list)

    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"
    return response
Example #2
0
def poll(request, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    view_id = request.GET.get('view_id')
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    response = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    return response
Example #3
0
File: api.py Project: rnoldo/sentry
def poll(request, team, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    response = _get_group_list(request=request, project=project)

    event_list = response["event_list"]
    event_list = list(event_list[offset:limit])

    return to_json(event_list, request)
Example #4
0
def poll(request, team, project):
    offset = 0
    limit = EVENTS_PER_PAGE

    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    return to_json(event_list, request)
Example #5
0
def clear(request, project):
    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list.update(status=1)

    data = []
    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #6
0
def clear(request, project):
    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list.update(status=1)

    data = []
    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #7
0
File: api.py Project: slafs/sentry
def poll(request, organization, project):
    offset = 0
    limit = EVENTS_PER_PAGE

    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    return to_json(event_list, request)
Example #8
0
def poll(request, project):
    from sentry.templatetags.sentry_helpers import as_bookmarks
    from sentry.templatetags.sentry_plugins import handle_before_events

    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    view_id = request.GET.get('view_id')
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    filters, event_list = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    event_list = list(event_list[offset:limit])
    handle_before_events(request, event_list)

    data = [{
        'id':
        m.pk,
        'html':
        render_to_string('sentry/partial/_group.html', {
            'group': m,
            'request': request,
            'is_bookmarked': b,
        }).strip(),
        'title':
        m.message_top(),
        'message':
        m.error(),
        'level':
        m.get_level_display(),
        'logger':
        m.logger,
        'count':
        m.times_seen,
        'score':
        getattr(m, 'sort_value', None),
    } for m, b in as_bookmarks(event_list, request.user)]

    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #9
0
def clear(request, project):
    response = _get_group_list(
        request=request,
        project=project,
    )

    # TODO: should we record some kind of global event in Activity?
    event_list = response['event_list']
    event_list.update(status=STATUS_RESOLVED)

    data = []
    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #10
0
File: api.py Project: rnoldo/sentry
def clear(request, team, project):
    response = _get_group_list(request=request, project=project)

    # TODO: should we record some kind of global event in Activity?
    event_list = response["event_list"]
    happened = event_list.update(status=STATUS_RESOLVED)

    if happened:
        Activity.objects.create(project=project, type=Activity.SET_RESOLVED, user=request.user)

    data = []
    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"
    return response
Example #11
0
def poll(request, organization, project):
    offset = 0
    limit = EVENTS_PER_PAGE

    group_result = _get_group_list(
        request=request,
        project=project,
    )

    event_list = group_result['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    links = [
        ('previous', str(group_result['prev_cursor'])),
        ('next', str(group_result['next_cursor'])),
    ]

    querystring = u'&'.join(
        u'{0}={1}'.format(urlquote(k), urlquote(v))
        for k, v in request.GET.iteritems()
        if k != 'cursor'
    )
    base_url = request.build_absolute_uri(request.path)
    if querystring:
        base_url = '{0}?{1}'.format(base_url, querystring)
    else:
        base_url = base_url + '?'

    link_values = []
    for name, cursor in links:
        link_values.append(LINK_HEADER.format(
            uri=base_url,
            cursor=cursor,
            name=name,
            has_results='true' if bool(cursor) else 'false',
        ))

    headers = {}
    if link_values:
        headers['Link'] = ', '.join(link_values)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    if link_values:
        response['Link'] = ', '.join(link_values)
    return response
Example #12
0
def poll(request, organization, project):
    offset = 0
    limit = EVENTS_PER_PAGE

    group_result = _get_group_list(
        request=request,
        project=project,
    )

    event_list = group_result['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    links = [
        ('previous', str(group_result['prev_cursor'])),
        ('next', str(group_result['next_cursor'])),
    ]

    querystring = u'&'.join(
        u'{0}={1}'.format(urlquote(k), urlquote(v))
        for k, v in request.GET.iteritems()
        if k != 'cursor'
    )
    base_url = request.build_absolute_uri(request.path)
    if querystring:
        base_url = '{0}?{1}'.format(base_url, querystring)
    else:
        base_url = base_url + '?'

    link_values = []
    for name, cursor in links:
        link_values.append(LINK_HEADER.format(
            uri=base_url,
            cursor=cursor,
            name=name,
            has_results='true' if bool(cursor) else 'false',
        ))

    headers = {}
    if link_values:
        headers['Link'] = ', '.join(link_values)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    if link_values:
        response['Link'] = ', '.join(link_values)
    return response
Example #13
0
def clear(request, team, project):
    response = _get_group_list(request=request, project=project)

    # TODO: should we record some kind of global event in Activity?
    event_list = response["event_list"]
    rows_affected = event_list.update(status=STATUS_RESOLVED)
    if rows_affected > 1000:
        logger.warning("Large resolve on %s of %s rows", project.slug, rows_affected)

    if rows_affected:
        Activity.objects.create(project=project, type=Activity.SET_RESOLVED, user=request.user)

    data = []
    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"
    return response
Example #14
0
def poll(request, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    return response
Example #15
0
def poll(request, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    return response
Example #16
0
def poll(request, project):
    from sentry.templatetags.sentry_helpers import as_bookmarks
    from sentry.templatetags.sentry_plugins import handle_before_events

    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    view_id = request.GET.get('view_id')
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    response = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])
    handle_before_events(request, event_list)

    data = [
        {
            'id': m.pk,
            'html': render_to_string('sentry/partial/_group.html', {
                'group': m,
                'request': request,
                'is_bookmarked': b,
            }).strip(),
            'title': m.message_top(),
            'message': m.error(),
            'level': m.get_level_display(),
            'logger': m.logger,
            'count': m.times_seen,
            'score': getattr(m, 'sort_value', None),
        } for m, b in as_bookmarks(event_list, request.user)]

    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #17
0
    def get(self, request, team, project):
        offset = 0
        limit = 100

        response = _get_group_list(
            request=request,
            project=project,
        )

        group_list = response['event_list']
        group_list = list(group_list[offset:limit])

        # TODO: need to make a custom serializer
        results = transform(group_list, request)
        for group in results:
            group['uri'] = absolute_uri(reverse('sentry-api-0-group-details', args=(team.slug, project.slug, group['id'])))

        return Response(results)
Example #18
0
File: api.py Project: rtnpro/sentry
def clear(request, project):
    view_id = request.GET.get("view_id")
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    _, event_list = _get_group_list(request=request, project=project, view=view)

    event_list.update(status=1)

    data = []
    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"
    return response
Example #19
0
    def get(self, request, team, project):
        offset = 0
        limit = 100

        response = _get_group_list(
            request=request,
            project=project,
        )

        group_list = response['event_list']
        group_list = list(group_list[offset:limit])

        # TODO: need to make a custom serializer
        results = transform(group_list, request)
        for group in results:
            group['uri'] = absolute_uri(
                reverse('sentry-api-0-group-details',
                        args=(team.slug, project.slug, group['id'])))

        return Response(results)
Example #20
0
File: api.py Project: rtnpro/sentry
def poll(request, project):
    from sentry.templatetags.sentry_helpers import as_bookmarks
    from sentry.templatetags.sentry_plugins import handle_before_events

    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    view_id = request.GET.get("view_id")
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    response = _get_group_list(request=request, project=project, view=view)

    event_list = response["event_list"]
    event_list = list(event_list[offset:limit])
    handle_before_events(request, event_list)

    data = [
        {
            "id": m.pk,
            "html": render_to_string(
                "sentry/partial/_group.html", {"group": m, "request": request, "is_bookmarked": b}
            ).strip(),
            "title": m.message_top(),
            "message": m.error(),
            "level": m.get_level_display(),
            "logger": m.logger,
            "count": m.times_seen,
            "score": getattr(m, "sort_value", None),
        }
        for m, b in as_bookmarks(event_list, request.user)
    ]

    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"
    return response
Example #21
0
def clear(request, team, project):
    response = _get_group_list(
        request=request,
        project=project,
    )

    # TODO: should we record some kind of global event in Activity?
    event_list = response['event_list']
    happened = event_list.update(status=STATUS_RESOLVED)

    if happened:
        Activity.objects.create(
            project=project,
            type=Activity.SET_RESOLVED,
            user=request.user,
        )

    data = []
    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #22
0
def clear(request, project):
    view_id = request.GET.get('view_id')
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    _, event_list = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    event_list.update(status=1)

    data = []
    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
Example #23
0
def clear(request, team, project):
    response = _get_group_list(
        request=request,
        project=project,
    )

    # TODO: should we record some kind of global event in Activity?
    event_list = response['event_list']
    rows_affected = event_list.update(status=STATUS_RESOLVED)
    if rows_affected > 1000:
        logger.warning('Large resolve on %s of %s rows', project.slug,
                       rows_affected)

    if rows_affected:
        Activity.objects.create(
            project=project,
            type=Activity.SET_RESOLVED,
            user=request.user,
        )

    data = []
    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'
    return response