• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python query.bulk_delete_objects函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.utils.query.bulk_delete_objects函数的典型用法代码示例。如果您正苦于以下问题:Python bulk_delete_objects函数的具体用法?Python bulk_delete_objects怎么用?Python bulk_delete_objects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bulk_delete_objects函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delete_tag_key

def delete_tag_key(object_id, continuous=True, **kwargs):
    from sentry.models import (
        EventTag, GroupTagKey, GroupTagValue, TagKey, TagKeyStatus, TagValue
    )

    try:
        tagkey = TagKey.objects.get(id=object_id)
    except TagKey.DoesNotExist:
        return

    if tagkey.status != TagKeyStatus.DELETION_IN_PROGRESS:
        tagkey.update(status=TagKeyStatus.DELETION_IN_PROGRESS)

    bulk_model_list = (
        GroupTagValue, GroupTagKey, TagValue
    )
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, project_id=tagkey.project_id,
                                       key=tagkey.key, logger=logger)
        if has_more:
            if continuous:
                delete_tag_key.delay(object_id=object_id, countdown=15)
            return

    has_more = bulk_delete_objects(EventTag, project_id=tagkey.project_id,
                                   key_id=tagkey.id, logger=logger)
    if has_more:
        if continuous:
            delete_tag_key.delay(object_id=object_id, countdown=15)
        return

    tagkey.delete()
开发者ID:WhoTrades,项目名称:sentry,代码行数:32,代码来源:deletion.py


示例2: delete_project

def delete_project(object_id, continuous=True, **kwargs):
    from sentry.models import (
        Activity, EventMapping, Group, GroupAssignee, GroupBookmark,
        GroupEmailThread, GroupHash, GroupMeta, GroupResolution,
        GroupRuleStatus, GroupSeen, GroupTagKey, GroupTagValue, Project,
        ProjectKey, ProjectStatus, SavedSearchUserDefault, SavedSearch, TagKey,
        TagValue, UserReport
    )

    try:
        p = Project.objects.get(id=object_id)
    except Project.DoesNotExist:
        return

    if p.status == ProjectStatus.VISIBLE:
        raise DeleteAborted('Aborting project deletion as status is invalid')

    if p.status != ProjectStatus.DELETION_IN_PROGRESS:
        pending_delete.send(sender=Project, instance=p)
        p.update(status=ProjectStatus.DELETION_IN_PROGRESS)

    # XXX: remove keys first to prevent additional data from flowing in
    model_list = (
        Activity, EventMapping, GroupAssignee, GroupBookmark, GroupEmailThread,
        GroupHash, GroupSeen, GroupRuleStatus, GroupTagKey,
        GroupTagValue, ProjectKey, TagKey, TagValue, SavedSearchUserDefault,
        SavedSearch, UserReport
    )
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return

    # TODO(dcramer): no project relation so we cant easily bulk
    # delete today
    has_more = delete_objects([GroupMeta, GroupResolution],
                              relation={'group__project': p},
                              logger=logger)
    if has_more:
        if continuous:
            delete_project.delay(object_id=object_id, countdown=15)
        return

    has_more = delete_events(relation={'project_id': p.id}, logger=logger)
    if has_more:
        if continuous:
            delete_project.delay(object_id=object_id, countdown=15)
        return

    model_list = (Group,)
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return
    p.delete()
开发者ID:ezc,项目名称:sentry,代码行数:59,代码来源:deletion.py


示例3: delete_group

def delete_group(object_id, continuous=True, **kwargs):
    from sentry.models import (
        EventMapping, Group, GroupHash, GroupRuleStatus, GroupStatus,
        GroupTagKey, GroupTagValue, GroupEmailThread,
    )

    try:
        group = Group.objects.get(id=object_id)
    except Group.DoesNotExist:
        return

    if group.status != GroupStatus.DELETION_IN_PROGRESS:
        group.update(status=GroupStatus.DELETION_IN_PROGRESS)

    bulk_model_list = (
        GroupHash, GroupRuleStatus, GroupTagValue, GroupTagKey,
        EventMapping, GroupEmailThread,
    )
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, group_id=object_id, logger=logger)
        if has_more:
            if continuous:
                delete_group.delay(object_id=object_id, countdown=15)
            return

    has_more = delete_events(relation={'group_id': object_id}, logger=logger)
    if has_more:
        if continuous:
            delete_group.delay(object_id=object_id, countdown=15)
        return
    group.delete()
开发者ID:zuiwanting,项目名称:sentry,代码行数:31,代码来源:deletion.py


示例4: delete_group

def delete_group(object_id, continuous=True, **kwargs):
    from sentry.models import (
        EventMapping, Group, GroupAssignee, GroupBookmark, GroupHash, GroupMeta,
        GroupResolution, GroupRuleStatus, GroupSnooze, GroupSubscription,
        GroupStatus, GroupTagKey, GroupTagValue, GroupEmailThread,
        GroupRedirect, UserReport
    )

    try:
        group = Group.objects.get(id=object_id)
    except Group.DoesNotExist:
        return

    if group.status != GroupStatus.DELETION_IN_PROGRESS:
        group.update(status=GroupStatus.DELETION_IN_PROGRESS)

    bulk_model_list = (
        # prioritize GroupHash
        GroupHash, GroupAssignee, GroupBookmark, GroupMeta, GroupResolution,
        GroupRuleStatus, GroupSnooze, GroupTagValue, GroupTagKey, EventMapping,
        GroupEmailThread, UserReport, GroupRedirect, GroupSubscription,
    )
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, group_id=object_id, logger=logger)
        if has_more:
            if continuous:
                delete_group.delay(object_id=object_id, countdown=15)
            return

    has_more = delete_events(relation={'group_id': object_id}, logger=logger)
    if has_more:
        if continuous:
            delete_group.delay(object_id=object_id, countdown=15)
        return
    group.delete()
开发者ID:BrunoAsato,项目名称:sentry,代码行数:35,代码来源:deletion.py


示例5: delete_group

def delete_group(object_id, continuous=True, **kwargs):
    from sentry.models import (
        Group, GroupHash, GroupRuleStatus, GroupTagKey, GroupTagValue,
        EventMapping
    )

    try:
        group = Group.objects.get(id=object_id)
    except Group.DoesNotExist:
        return

    bulk_model_list = (
        GroupHash, GroupRuleStatus, GroupTagValue, GroupTagKey, EventMapping
    )
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, group_id=object_id, logger=logger)
        if has_more:
            if continuous:
                delete_group.delay(object_id=object_id, countdown=15)
            return

    has_more = delete_events(relation={'group_id': object_id}, logger=logger)
    if has_more:
        if continuous:
            delete_group.delay(object_id=object_id, countdown=15)
        return
    group.delete()
开发者ID:KinKir,项目名称:sentry,代码行数:27,代码来源:deletion.py


示例6: delete_project

def delete_project(object_id, continuous=True, **kwargs):
    from sentry.models import (
        Project, ProjectKey, ProjectStatus, TagKey, TagValue, GroupTagKey,
        GroupTagValue, Activity, EventMapping, Group, GroupEmailThread,
        GroupRuleStatus, GroupHash, GroupSeen, UserReport
    )

    try:
        p = Project.objects.get(id=object_id)
    except Project.DoesNotExist:
        return

    if p.status == ProjectStatus.VISIBLE:
        raise DeleteAborted('Aborting project deletion as status is invalid')

    if p.status != ProjectStatus.DELETION_IN_PROGRESS:
        pending_delete.send(sender=Project, instance=p)
        p.update(status=ProjectStatus.DELETION_IN_PROGRESS)

    # XXX: remove keys first to prevent additional data from flowing in
    model_list = (
        ProjectKey, TagKey, TagValue, GroupTagKey, GroupTagValue, EventMapping,
        Activity, GroupRuleStatus, GroupHash, GroupSeen, UserReport,
        GroupEmailThread
    )
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return

    has_more = delete_events(relation={'project_id': p.id}, logger=logger)
    if has_more:
        if continuous:
            delete_project.delay(object_id=object_id, countdown=15)
        return

    model_list = (Group,)
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return
    p.delete()
开发者ID:dseremet,项目名称:sentry,代码行数:46,代码来源:deletion.py


示例7: delete_tag_key

def delete_tag_key(object_id, transaction_id=None, continuous=True, **kwargs):
    from sentry.models import (
        EventTag, GroupTagKey, GroupTagValue, TagKey, TagKeyStatus, TagValue
    )

    try:
        tagkey = TagKey.objects.get(id=object_id)
    except TagKey.DoesNotExist:
        return

    if tagkey.status != TagKeyStatus.DELETION_IN_PROGRESS:
        tagkey.update(status=TagKeyStatus.DELETION_IN_PROGRESS)

    bulk_model_list = (
        GroupTagValue, GroupTagKey, TagValue
    )
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, project_id=tagkey.project_id,
                                       key=tagkey.key, logger=logger)
        if has_more:
            if continuous:
                delete_tag_key.apply_async(
                    kwargs={'object_id': object_id, 'transaction_id': transaction_id},
                    countdown=15,
                )
            return

    has_more = bulk_delete_objects(EventTag, project_id=tagkey.project_id,
                                   key_id=tagkey.id, logger=logger)
    if has_more:
        if continuous:
            delete_tag_key.apply_async(
                kwargs={'object_id': object_id, 'transaction_id': transaction_id},
                countdown=15,
            )
        return

    tagkey_id = tagkey.id
    tagkey.delete()
    logger.info('object.delete.executed', extra={
        'object_id': tagkey_id,
        'transaction_id': transaction_id,
        'model': TagKey.__name__,
    })
开发者ID:ForkRepo,项目名称:sentry,代码行数:44,代码来源:deletion.py


示例8: delete_project

def delete_project(object_id, continuous=True, **kwargs):
    from sentry.models import (
        Project, ProjectKey, ProjectStatus, TagKey, TagValue, GroupTagKey,
        GroupTagValue, Activity, EventMapping, Group, GroupRuleStatus,
        GroupHash, GroupSeen,
    )

    try:
        p = Project.objects.get(id=object_id)
    except Project.DoesNotExist:
        return

    if p.status != ProjectStatus.DELETION_IN_PROGRESS:
        p.update(status=ProjectStatus.DELETION_IN_PROGRESS)

    # XXX: remove keys first to prevent additional data from flowing in
    model_list = (
        ProjectKey, TagKey, TagValue, GroupTagKey, GroupTagValue, EventMapping,
        Activity, GroupRuleStatus, GroupHash, GroupSeen,
    )
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return

    has_more = delete_events(relation={'project_id': p.id}, logger=logger)
    if has_more:
        if continuous:
            delete_project.delay(object_id=object_id, countdown=15)
        return

    model_list = (Group,)
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return
    p.delete()
开发者ID:zuiwanting,项目名称:sentry,代码行数:41,代码来源:deletion.py


示例9: delete_group

def delete_group(object_id, transaction_id=None, continuous=True, **kwargs):
    from sentry.models import (
        EventMapping, Group, GroupAssignee, GroupBookmark, GroupCommitResolution,
        GroupHash, GroupMeta, GroupRelease, GroupResolution, GroupRuleStatus,
        GroupSnooze, GroupSubscription, GroupStatus, GroupTagKey, GroupTagValue,
        GroupEmailThread, GroupRedirect, UserReport
    )

    try:
        group = Group.objects.get(id=object_id)
    except Group.DoesNotExist:
        return

    if group.status != GroupStatus.DELETION_IN_PROGRESS:
        group.update(status=GroupStatus.DELETION_IN_PROGRESS)

    bulk_model_list = (
        # prioritize GroupHash
        GroupHash, GroupAssignee, GroupCommitResolution, GroupBookmark,
        GroupMeta, GroupRelease, GroupResolution, GroupRuleStatus, GroupSnooze,
        GroupTagValue, GroupTagKey, EventMapping, GroupEmailThread, GroupRedirect,
        GroupSubscription, UserReport,
    )
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, group_id=object_id, logger=logger)
        if has_more:
            if continuous:
                delete_group.apply_async(
                    kwargs={'object_id': object_id, 'transaction_id': transaction_id},
                    countdown=15,
                )
            return

    has_more = delete_events(relation={'group_id': object_id}, logger=logger)
    if has_more:
        if continuous:
            delete_group.apply_async(
                kwargs={'object_id': object_id, 'transaction_id': transaction_id},
            )
        return

    features.delete(group)
    g_id = group.id
    group.delete()
    logger.info('object.delete.executed', extra={
        'object_id': g_id,
        'transaction_id': transaction_id,
        'model': Group.__name__,
    })
开发者ID:sashahilton00,项目名称:sentry,代码行数:49,代码来源:deletion.py


示例10: delete_api_application

def delete_api_application(object_id, transaction_id=None, continuous=True,
                           **kwargs):
    from sentry.models import ApiApplication, ApiApplicationStatus, ApiGrant

    try:
        app = ApiApplication.objects.get(id=object_id)
    except ApiApplication.DoesNotExist:
        return

    if app.status == ApiApplicationStatus.active:
        raise DeleteAborted

    if app.status != ApiApplicationStatus.deletion_in_progress:
        app.update(status=ApiApplicationStatus.deletion_in_progress)

    has_more = revoke_api_tokens(object_id)
    if has_more:
        if continuous:
            delete_api_application.apply_async(
                kwargs={
                    'object_id': object_id,
                    'transaction_id': transaction_id,
                },
                countdown=15,
            )
        return

    bulk_model_list = (ApiGrant,)
    for model in bulk_model_list:
        has_more = bulk_delete_objects(model, application_id=app.id,
                                       logger=logger)
        if has_more:
            if continuous:
                delete_api_application.apply_async(
                    kwargs={
                        'object_id': object_id,
                        'transaction_id': transaction_id,
                    },
                    countdown=15,
                )
            return

    app.delete()
    logger.info('object.delete.executed', extra={
        'object_id': object_id,
        'transaction_id': transaction_id,
        'model': ApiApplication.__name__,
    })
开发者ID:sashahilton00,项目名称:sentry,代码行数:48,代码来源:deletion.py


示例11: delete_instance_bulk

 def delete_instance_bulk(self):
     try:
         return bulk_delete_objects(
             model=self.model,
             limit=self.chunk_size,
             transaction_id=self.transaction_id,
             **self.query
         )
     finally:
         # Don't log Group and Event child object deletions.
         model_name = self.model.__name__
         if not _leaf_re.search(model_name):
             self.logger.info(
                 'object.delete.bulk_executed',
                 extra=dict(
                     {
                         'transaction_id': self.transaction_id,
                         'app_label': self.model._meta.app_label,
                         'model': model_name,
                     }, **self.query
                 )
             )
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:22,代码来源:base.py


示例12: delete_project

def delete_project(object_id, transaction_id=None, continuous=True, **kwargs):
    from sentry.models import (
        Activity, EventMapping, EventUser, Group, GroupAssignee, GroupBookmark,
        GroupEmailThread, GroupHash, GroupMeta, GroupRelease, GroupResolution,
        GroupRuleStatus, GroupSeen, GroupSubscription, GroupSnooze, GroupTagKey,
        GroupTagValue, Project, ProjectBookmark, ProjectKey, ProjectStatus,
        Release, ReleaseFile, SavedSearchUserDefault, SavedSearch, TagKey,
        TagValue, UserReport, ReleaseEnvironment, Environment
    )

    try:
        p = Project.objects.get(id=object_id)
    except Project.DoesNotExist:
        return

    if p.status == ProjectStatus.VISIBLE:
        raise DeleteAborted('Aborting project deletion as status is invalid')

    if p.status != ProjectStatus.DELETION_IN_PROGRESS:
        pending_delete.send(sender=Project, instance=p)
        p.update(status=ProjectStatus.DELETION_IN_PROGRESS)

    # Immediately revoke keys
    project_keys = list(ProjectKey.objects.filter(project_id=object_id).values_list('id', flat=True))
    ProjectKey.objects.filter(project_id=object_id).delete()
    for key_id in project_keys:
        logger.info('object.delete.executed', extra={
            'object_id': key_id,
            'transaction_id': transaction_id,
            'model': ProjectKey.__name__,
        })

    model_list = (
        Activity, EventMapping, EventUser, GroupAssignee, GroupBookmark,
        GroupEmailThread, GroupHash, GroupRelease, GroupRuleStatus, GroupSeen,
        GroupSubscription, GroupTagKey, GroupTagValue, ProjectBookmark,
        ProjectKey, TagKey, TagValue, SavedSearchUserDefault, SavedSearch,
        UserReport, ReleaseEnvironment, Environment
    )
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, transaction_id=transaction_id, logger=logger)
        if has_more:
            if continuous:
                delete_project.apply_async(
                    kwargs={'object_id': object_id, 'transaction_id': transaction_id},
                    countdown=15,
                )
            return

    # TODO(dcramer): no project relation so we cant easily bulk
    # delete today
    has_more = delete_objects([GroupMeta, GroupResolution, GroupSnooze],
                              relation={'group__project': p},
                              transaction_id=transaction_id,
                              logger=logger)
    if has_more:
        if continuous:
            delete_project.apply_async(
                kwargs={'object_id': object_id, 'transaction_id': transaction_id},
                countdown=15,
            )
        return

    has_more = delete_events(relation={'project_id': p.id}, transaction_id=transaction_id, logger=logger)
    if has_more:
        if continuous:
            delete_project.apply_async(
                kwargs={'object_id': object_id, 'transaction_id': transaction_id},
            )
        return

    # Release needs to handle deletes after Group is cleaned up as the foreign
    # key is protected
    model_list = (Group, ReleaseFile, Release)
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, transaction_id=transaction_id, logger=logger)
        if has_more:
            if continuous:
                delete_project.apply_async(
                    kwargs={'object_id': object_id, 'transaction_id': transaction_id},
                    countdown=15,
                )
            return

    p_id = p.id
    p.delete()
    logger.info('object.delete.queued', extra={
        'object_id': p_id,
        'transaction_id': transaction_id,
        'model': Project.__name__,
    })
开发者ID:ForkRepo,项目名称:sentry,代码行数:91,代码来源:deletion.py


示例13: delete_project

def delete_project(object_id, continuous=True, **kwargs):
    from sentry.models import (
        Activity, EventMapping, Group, GroupAssignee, GroupBookmark,
        GroupEmailThread, GroupHash, GroupMeta, GroupResolution,
        GroupRuleStatus, GroupSeen, GroupTagKey, GroupTagValue, Project,
        ProjectBookmark, ProjectKey, ProjectStatus, Release, ReleaseFile,
        SavedSearchUserDefault, SavedSearch, TagKey, TagValue, UserReport
    )

    try:
        p = Project.objects.get(id=object_id)
    except Project.DoesNotExist:
        return

    if p.status == ProjectStatus.VISIBLE:
        raise DeleteAborted('Aborting project deletion as status is invalid')

    if p.status != ProjectStatus.DELETION_IN_PROGRESS:
        pending_delete.send(sender=Project, instance=p)
        p.update(status=ProjectStatus.DELETION_IN_PROGRESS)

    # Immediately revoke keys
    ProjectKey.objects.filter(project_id=object_id).delete()

    model_list = (
        Activity, EventMapping, GroupAssignee, GroupBookmark, GroupEmailThread,
        GroupHash, GroupSeen, GroupRuleStatus, GroupTagKey, GroupTagValue,
        ProjectBookmark, ProjectKey, TagKey, TagValue, SavedSearchUserDefault,
        SavedSearch, UserReport
    )
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return

    # TODO(dcramer): no project relation so we cant easily bulk
    # delete today
    has_more = delete_objects([GroupMeta, GroupResolution],
                              relation={'group__project': p},
                              logger=logger)
    if has_more:
        if continuous:
            delete_project.delay(object_id=object_id, countdown=15)
        return

    has_more = delete_events(relation={'project_id': p.id}, logger=logger)
    if has_more:
        if continuous:
            delete_project.delay(object_id=object_id, countdown=15)
        return

    # Release needs to handle deletes after Group is cleaned up as the foreign
    # key is protected
    model_list = (Group, ReleaseFile, Release)
    for model in model_list:
        has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
        if has_more:
            if continuous:
                delete_project.delay(object_id=object_id, countdown=15)
            return

    p.delete()
开发者ID:IthacaDream,项目名称:sentry,代码行数:64,代码来源:deletion.py



注:本文中的sentry.utils.query.bulk_delete_objects函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python queue.maybe_delay函数代码示例发布时间:2022-05-27
下一篇:
Python metrics.timing函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap