当前位置: 首页>>代码示例>>Python>>正文


Python models.EventUser类代码示例

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


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

示例1: _get_event_user

    def _get_event_user(self, project, data):
        user_data = data.get("sentry.interfaces.User")
        if not user_data:
            return

        euser = EventUser(
            project=project,
            ident=user_data.get("id"),
            email=user_data.get("email"),
            username=user_data.get("username"),
            ip_address=user_data.get("ip_address"),
        )

        if not euser.tag_value:
            return

        cache_key = "euser:{}:{}".format(project.id, md5(euser.tag_value.encode("utf-8")).hexdigest())
        cached = default_cache.get(cache_key)
        if cached is None:
            try:
                with transaction.atomic(using=router.db_for_write(EventUser)):
                    euser.save()
            except IntegrityError:
                pass
            default_cache.set(cache_key, "", 3600)

        return euser
开发者ID:yoachum,项目名称:sentry,代码行数:27,代码来源:event_manager.py

示例2: _get_event_user

    def _get_event_user(self, project, data):
        user_data = data.get('sentry.interfaces.User')
        if not user_data:
            return

        euser = EventUser(
            project=project,
            ident=user_data.get('id'),
            email=user_data.get('email'),
            username=user_data.get('username'),
            ip_address=user_data.get('ip_address'),
        )

        if not euser.tag_value:
            return

        cache_key = 'euser:{}:{}'.format(
            project.id,
            md5_text(euser.tag_value).hexdigest(),
        )
        cached = default_cache.get(cache_key)
        if cached is None:
            try:
                with transaction.atomic(using=router.db_for_write(EventUser)):
                    euser.save()
            except IntegrityError:
                pass
            default_cache.set(cache_key, '', 3600)

        return euser
开发者ID:mvaled,项目名称:sentry,代码行数:30,代码来源:event_manager.py

示例3: record_affected_user

def record_affected_user(event, **kwargs):
    from sentry.models import EventUser, Group

    user_data = event.data.get('sentry.interfaces.User', event.data.get('user'))
    if not user_data:
        logger.info('No user data found for event_id=%s', event.event_id)
        return

    euser = EventUser(
        project=event.project,
        ident=user_data.get('id'),
        email=user_data.get('email'),
        username=user_data.get('username'),
        ip_address=user_data.get('ip_address'),
    )

    if not euser.tag_value:
        # no ident, bail
        logger.info('No identifying value found for user on event_id=%s',
                    event.event_id)
        return

    try:
        with transaction.atomic():
            euser.save()
    except IntegrityError:
        pass

    Group.objects.add_tags(event.group, [
        ('sentry:user', euser.tag_value)
    ])
开发者ID:haojiang1,项目名称:sentry,代码行数:31,代码来源:post_process.py

示例4: test_for_tags

 def test_for_tags(self):
     eu = EventUser.objects.create(
         project_id=1,
         ident='matt',
     )
     assert EventUser.for_tags(1, ['id:matt']) == {'id:matt': eu}
     assert EventUser.for_tags(1, ['id:doesnotexist']) == {}
     assert EventUser.for_tags(1, ['id:matt', 'id:doesnotexist']) == {'id:matt': eu}
开发者ID:Kayle009,项目名称:sentry,代码行数:8,代码来源:test_eventuser.py

示例5: find_event_user

    def find_event_user(self, report):
        try:
            event = Event.objects.get(
                group_id=report.group_id,
                event_id=report.event_id,
            )
        except Event.DoesNotExist:
            if not report.email:
                return None
            try:
                return EventUser.objects.filter(
                    project_id=report.project_id,
                    email=report.email,
                )[0]
            except IndexError:
                return None

        tag = event.get_tag('sentry:user')
        if not tag:
            return None

        try:
            return EventUser.for_tags(
                project_id=report.project_id,
                values=[tag],
            )[tag]
        except KeyError:
            pass
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:28,代码来源:project_user_reports.py

示例6: get_attrs

    def get_attrs(self, item_list, user):
        users = EventUser.for_tags(project_id=item_list[0].project_id, values=[t.value for t in item_list])

        result = {}
        for item in item_list:
            result[item] = {"user": users.get(item.value)}
        return result
开发者ID:pythorn,项目名称:sentry,代码行数:7,代码来源:tagvalue.py

示例7: test_attr_from_keyword

 def test_attr_from_keyword(self):
     cases = [
         ('id', 'ident'),
         ('username', 'username'),
         ('email', 'email'),
         ('ip', 'ip_address'),
     ]
     for keyword, attr in cases:
         assert EventUser.attr_from_keyword(keyword) == attr
开发者ID:binlee1990,项目名称:sentry,代码行数:9,代码来源:test_eventuser.py

示例8: get_user_tag

def get_user_tag(project, key, value):
    # TODO(dcramer): do something with case of multiple matches
    try:
        lookup = EventUser.attr_from_keyword(key)
        euser = EventUser.objects.filter(project=project, **{lookup: value})[0]
    except (KeyError, IndexError):
        return "{}:{}".format(key, value)

    return euser.tag_value
开发者ID:zhoupan,项目名称:sentry,代码行数:9,代码来源:utils.py

示例9: serialize_eventusers

def serialize_eventusers(organization, item_list, user, lookup):
    if not item_list:
        return {}

    # We have no reliable way to map the tag value format
    # back into real EventUser rows. EventUser is only unique
    # per-project, and this is an organization aggregate.
    # This means a single value maps to multiple rows.
    filters = reduce(or_, [
        Q(hash=EventUser.hash_from_tag(tag), project_id=project)
        for tag, project in item_list
    ])

    eu_by_key = {
        (eu.tag_value, eu.project_id): eu
        for eu in EventUser.objects.filter(filters)
    }

    projects = serialize_projects(organization, {i[1] for i in item_list}, user)

    rv = {}
    for tag, project in item_list:
        eu = eu_by_key.get((tag, project))
        if eu is None:
            attr, value = tag.split(':', 1)
            eu = EventUser(project_id=project, **{EventUser.attr_from_keyword(attr): value})
        rv[(tag, project)] = {
            HEALTH_ID_KEY: make_health_id(lookup, [eu.tag_value, eu.project_id]),
            'value': {
                'id': six.text_type(eu.id) if eu.id else None,
                'project': projects.get(eu.project_id),
                'hash': eu.hash,
                'tagValue': eu.tag_value,
                'identifier': eu.ident,
                'username': eu.username,
                'email': eu.email,
                'ipAddress': eu.ip_address,
                'dateCreated': eu.date_added,
                'label': eu.get_label(),
                'name': eu.get_display_name(),
                'geo': geo_by_addr(eu.ip_address),
            },
        }
    return rv
开发者ID:Kayle009,项目名称:sentry,代码行数:44,代码来源:snuba.py

示例10: get_user_tag

def get_user_tag(project, key, value):
    # TODO(dcramer): do something with case of multiple matches
    try:
        lookup = EventUser.attr_from_keyword(key)
        euser = EventUser.objects.filter(
            project_id=project.id, **{lookup: value})[0]
    except (KeyError, IndexError):
        return u'{}:{}'.format(key, value)
    except DataError:
        raise InvalidQuery(u"malformed '{}:' query '{}'.".format(key, value))
    return euser.tag_value
开发者ID:binlee1990,项目名称:sentry,代码行数:11,代码来源:utils.py

示例11: get_attrs

    def get_attrs(self, item_list, user):
        users = EventUser.for_tags(
            project_id=self.project_id,
            values=[t.value for t in item_list],
        )

        result = {}
        for item in item_list:
            result[item] = {
                'user': users.get(item.value),
            }
        return result
开发者ID:Kayle009,项目名称:sentry,代码行数:12,代码来源:tagvalue.py

示例12: _get_event_user

    def _get_event_user(self, project, data):
        user_data = data.get('sentry.interfaces.User')
        if not user_data:
            return

        euser = EventUser(
            project=project,
            ident=user_data.get('id'),
            email=user_data.get('email'),
            username=user_data.get('username'),
            ip_address=user_data.get('ip_address'),
        )

        if not euser.tag_value:
            return

        try:
            with transaction.atomic():
                euser.save()
        except IntegrityError:
            pass

        return euser
开发者ID:delkyd,项目名称:sentry,代码行数:23,代码来源:event_manager.py

示例13: _get_event_user

    def _get_event_user(self, project, data):
        user_data = data.get('sentry.interfaces.User')
        if not user_data:
            return

        euser = EventUser(
            project_id=project.id,
            ident=user_data.get('id'),
            email=user_data.get('email'),
            username=user_data.get('username'),
            ip_address=user_data.get('ip_address'),
            name=user_data.get('name'),
        )
        euser.set_hash()
        if not euser.hash:
            return

        cache_key = 'euserid:1:{}:{}'.format(
            project.id,
            euser.hash,
        )
        euser_id = default_cache.get(cache_key)
        if euser_id is None:
            try:
                with transaction.atomic(using=router.db_for_write(EventUser)):
                    euser.save()
            except IntegrityError:
                try:
                    euser = EventUser.objects.get(
                        project_id=project.id,
                        hash=euser.hash,
                    )
                except EventUser.DoesNotExist:
                    # why???
                    e_userid = -1
                else:
                    if euser.name != (user_data.get('name') or euser.name):
                        euser.update(
                            name=user_data['name'],
                        )
                    e_userid = euser.id
                default_cache.set(cache_key, e_userid, 3600)
        return euser
开发者ID:alshopov,项目名称:sentry,代码行数:43,代码来源:event_manager.py

示例14: get

    def get(self, request, project):
        """
        List a Project's Users
        ``````````````````````

        Return a list of users seen within this project.

        :pparam string organization_slug: the slug of the organization.
        :pparam string project_slug: the slug of the project.
        :pparam string key: the tag key to look up.
        :auth: required
        :qparam string query: Limit results to users matching the given query.
                              Prefixes should be used to suggest the field to
                              match on: ``id``, ``email``, ``username``, ``ip``.
                              For example, ``query=email:[email protected]``
        """
        queryset = EventUser.objects.filter(
            project_id=project.id,
        )
        if request.GET.get('query'):
            pieces = request.GET['query'].strip().split(':', 1)
            if len(pieces) != 2:
                return Response([])
            try:
                queryset = queryset.filter(
                    **{u'{}__icontains'.format(EventUser.attr_from_keyword(pieces[0])): pieces[1]}
                )
            except KeyError:
                return Response([])

        return self.paginate(
            request=request,
            queryset=queryset,
            order_by='-date_added',
            paginator_cls=DateTimePaginator,
            on_results=lambda x: serialize(x, request.user),
        )
开发者ID:Kayle009,项目名称:sentry,代码行数:37,代码来源:project_users.py

示例15: test_hash_from_tag

 def test_hash_from_tag(self):
     assert EventUser.hash_from_tag('foo:bar:baz') == md5('bar:baz').hexdigest()
开发者ID:Kayle009,项目名称:sentry,代码行数:2,代码来源:test_eventuser.py


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