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


Python EventUser.attr_from_keyword方法代码示例

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


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

示例1: get_user_tag

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import attr_from_keyword [as 别名]
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,代码行数:11,代码来源:utils.py

示例2: test_attr_from_keyword

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import attr_from_keyword [as 别名]
 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,代码行数:11,代码来源:test_eventuser.py

示例3: get_user_tag

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import attr_from_keyword [as 别名]
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,代码行数:13,代码来源:utils.py

示例4: serialize_eventusers

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import attr_from_keyword [as 别名]
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,代码行数:46,代码来源:snuba.py

示例5: get

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import attr_from_keyword [as 别名]
    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,代码行数:39,代码来源:project_users.py


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