示例#1
0
def delete_events(relation, transaction_id=None, limit=100, logger=None):
    from sentry.app import nodestore
    from sentry.models import Event, EventTag

    has_more = False
    if logger is not None:
        # The only reason this is a different log statement is that logging every
        # single event that gets deleted in the relation will destroy disks.
        logger.info('object.delete.bulk_executed', extra=dict(
            relation.items() + [('transaction_id', transaction_id)],
        ))

    result_set = list(Event.objects.filter(**relation)[:limit])
    has_more = bool(result_set)
    if has_more:
        # delete objects from nodestore first
        node_ids = set(r.data.id for r in result_set if r.data.id)
        if node_ids:
            nodestore.delete_multi(node_ids)

        event_ids = [r.id for r in result_set]

        # bulk delete by id
        EventTag.objects.filter(event_id__in=event_ids).delete()
        Event.objects.filter(id__in=event_ids).delete()
    return has_more
示例#2
0
def delete_events(relation, transaction_id=None, limit=100, logger=None):
    from sentry.app import nodestore
    from sentry.models import Event, EventTag

    has_more = False
    if logger is not None:
        logger.info('remove.event',
                    extra=dict(
                        relation.items() +
                        [('transaction_id', transaction_id)], ))

    result_set = list(Event.objects.filter(**relation)[:limit])
    has_more = bool(result_set)
    if has_more:
        # delete objects from nodestore first
        node_ids = set(r.data.id for r in result_set if r.data.id)
        if node_ids:
            nodestore.delete_multi(node_ids)

        event_ids = [r.id for r in result_set]

        # bulk delete by id
        EventTag.objects.filter(event_id__in=event_ids).delete()
        Event.objects.filter(id__in=event_ids).delete()
    return has_more
示例#3
0
文件: deletion.py 项目: ovwane/Sentry
def delete_events(relation, limit=100, logger=None):
    from sentry.app import nodestore
    from sentry.models import Event

    has_more = False
    if logger is not None:
        logger.info('Removing %r objects where %r', Event, relation)

    result_set = list(Event.objects.filter(**relation)[:limit])
    has_more = bool(result_set)
    if has_more:
        # delete objects from nodestore first
        node_ids = set(r.data.id for r in result_set)
        nodestore.delete_multi(node_ids)

        # bulk delete by id
        Event.objects.filter(id__in=[r.id for r in result_set]).delete()
    return has_more
示例#4
0
def delete_events(relation, limit=100, logger=None):
    from sentry.app import nodestore
    from sentry.models import Event

    has_more = False
    if logger is not None:
        logger.info('Removing %r objects where %r', Event, relation)

    result_set = list(Event.objects.filter(**relation)[:limit])
    has_more = bool(result_set)
    if has_more:
        # delete objects from nodestore first
        node_ids = set(r.data.id for r in result_set)
        nodestore.delete_multi(node_ids)

        # bulk delete by id
        Event.objects.filter(id__in=[r.id for r in result_set]).delete()
    return has_more