0132_add_default_orgs.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Sentry 作者: NetEaseGame 项目源码 文件源码
def forwards(self, orm):
        from sentry.utils.query import RangeQuerySetWrapperWithProgressBar

        Organization = orm['sentry.Organization']
        Team = orm['sentry.Team']

        queryset = Team.objects.filter(
            organization__isnull=True,
        )

        user_orgs = {}
        for team in RangeQuerySetWrapperWithProgressBar(queryset):
            if team.owner_id not in user_orgs:
                user_orgs[team.owner_id] = Organization.objects.create(
                    name=team.name.strip() or 'Default',
                    owner_id=team.owner_id,
                )

            team.organization = user_orgs[team.owner_id]
            team.save()
            transaction.commit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号