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


Python TAG_LABELS.get方法代码示例

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


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

示例1: get_attrs

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def get_attrs(self, item_list, user):
        from sentry.plugins import plugins

        GroupMeta.objects.populate_cache(item_list)

        attach_foreignkey(item_list, Group.project, ["team"])

        if user.is_authenticated() and item_list:
            bookmarks = set(
                GroupBookmark.objects.filter(user=user, group__in=item_list).values_list("group_id", flat=True)
            )
            seen_groups = dict(
                GroupSeen.objects.filter(user=user, group__in=item_list).values_list("group_id", "last_seen")
            )
        else:
            bookmarks = set()
            seen_groups = {}

        tag_counts = defaultdict(dict)
        tag_results = GroupTagKey.objects.filter(group__in=item_list).values_list("key", "group", "values_seen")
        for key, group_id, values_seen in tag_results:
            tag_counts[key][group_id] = values_seen

        assignees = dict(
            (a.group_id, a.user) for a in GroupAssignee.objects.filter(group__in=item_list).select_related("user")
        )

        result = {}
        for item in item_list:
            active_date = item.active_at or item.last_seen

            tags = {}
            for key in tag_counts.iterkeys():
                label = TAG_LABELS.get(key, key.replace("_", " ")).lower()
                try:
                    value = tag_counts[key].get(item.id, 0)
                except KeyError:
                    value = 0
                tags[key] = {"label": label, "count": value}

            annotations = []
            for plugin in plugins.for_project(project=item.project, version=1):
                safe_execute(plugin.tags, None, item, annotations)
            for plugin in plugins.for_project(project=item.project, version=2):
                annotations.extend(safe_execute(plugin.get_annotations, item) or ())

            result[item] = {
                "assigned_to": serialize(assignees.get(item.id)),
                "is_bookmarked": item.id in bookmarks,
                "has_seen": seen_groups.get(item.id, active_date) > active_date,
                "tags": tags,
                "annotations": annotations,
            }
        return result
开发者ID:Qwiz,项目名称:sentry,代码行数:56,代码来源:group.py

示例2: get_attrs

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def get_attrs(self, item_list, user):
        attach_foreignkey(item_list, Group.project, ['team'])

        if user.is_authenticated() and item_list:
            bookmarks = set(GroupBookmark.objects.filter(
                user=user,
                group__in=item_list,
            ).values_list('group_id', flat=True))
            seen_groups = dict(GroupSeen.objects.filter(
                user=user,
                group__in=item_list,
            ).values_list('group_id', 'last_seen'))
        else:
            bookmarks = set()
            seen_groups = {}

        tag_counts = defaultdict(dict)
        tag_results = GroupTagKey.objects.filter(
            group__in=item_list,
        ).values_list('key', 'group', 'values_seen')
        for key, group_id, values_seen in tag_results:
            tag_counts[key][group_id] = values_seen

        assignees = dict(
            (a.group_id, a.user)
            for a in GroupAssignee.objects.filter(
                group__in=item_list,
            ).select_related('user')
        )

        result = {}
        for item in item_list:
            active_date = item.active_at or item.last_seen

            tags = {}
            for key in tag_counts.iterkeys():
                label = TAG_LABELS.get(key, key.replace('_', ' ')).lower()
                try:
                    value = tag_counts[key].get(item.id, 0)
                except KeyError:
                    value = 0
                tags[key] = {
                    'label': label,
                    'count': value,
                }

            result[item] = {
                'assigned_to': serialize(assignees.get(item.id)),
                'is_bookmarked': item.id in bookmarks,
                'has_seen': seen_groups.get(item.id, active_date) > active_date,
                'tags': tags,
            }
        return result
开发者ID:KinKir,项目名称:sentry,代码行数:55,代码来源:group.py

示例3: attach_metadata

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def attach_metadata(self, objects, request=None):
        from sentry.templatetags.sentry_plugins import handle_before_events

        attach_foreignkey(objects, Group.project, ["team"])

        if request and objects:
            handle_before_events(request, objects)

        if request and request.user.is_authenticated() and objects:
            bookmarks = set(
                GroupBookmark.objects.filter(user=request.user, group__in=objects).values_list("group_id", flat=True)
            )
            seen_groups = dict(
                GroupSeen.objects.filter(user=request.user, group__in=objects).values_list("group_id", "last_seen")
            )
        else:
            bookmarks = set()
            seen_groups = {}

        if objects:
            historical_data = Group.objects.get_chart_data_for_group(instances=objects, max_days=1, key="group")
        else:
            historical_data = {}

        project_list = set(o.project for o in objects)
        tag_keys = set(["sentry:user"])
        project_annotations = {}
        for project in project_list:
            enabled_annotations = ProjectOption.objects.get_value(project, "annotations", ["sentry:user"])
            project_annotations[project] = enabled_annotations
            tag_keys.update(enabled_annotations)

        annotation_counts = defaultdict(dict)
        annotation_results = GroupTagKey.objects.filter(group__in=objects, key__in=tag_keys).values_list(
            "key", "group", "values_seen"
        )
        for key, group_id, values_seen in annotation_results:
            annotation_counts[key][group_id] = values_seen

        for g in objects:
            g.is_bookmarked = g.pk in bookmarks
            g.historical_data = [x[1] for x in historical_data.get(g.id, [])]
            active_date = g.active_at or g.last_seen
            g.has_seen = seen_groups.get(g.id, active_date) > active_date
            g.annotations = []
            for key in sorted(tag_keys):
                if key in project_annotations[project]:
                    label = TAG_LABELS.get(key, key.replace("_", " ")).lower() + "s"
                    try:
                        value = annotation_counts[key].get(g.id, 0)
                    except KeyError:
                        value = 0
                    g.annotations.append({"label": label, "count": value})
开发者ID:beyondtime,项目名称:sentry,代码行数:55,代码来源:javascript.py

示例4: attach_metadata

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def attach_metadata(self, objects, user):
        attach_foreignkey(objects, Group.project, ['team'])

        # if request and objects:
        #     handle_before_events(request, objects)

        if user.is_authenticated() and objects:
            bookmarks = set(GroupBookmark.objects.filter(
                user=user,
                group__in=objects,
            ).values_list('group_id', flat=True))
            seen_groups = dict(GroupSeen.objects.filter(
                user=user,
                group__in=objects,
            ).values_list('group_id', 'last_seen'))
        else:
            bookmarks = set()
            seen_groups = {}

        project_list = set(o.project for o in objects)
        tag_keys = set(['sentry:user'])
        project_annotations = {}
        for project in project_list:
            enabled_annotations = ProjectOption.objects.get_value(
                project, 'annotations', ['sentry:user'])
            project_annotations[project] = enabled_annotations
            tag_keys.update(enabled_annotations)

        annotation_counts = defaultdict(dict)
        annotation_results = GroupTagKey.objects.filter(
            group__in=objects,
            key__in=tag_keys,
        ).values_list('key', 'group', 'values_seen')
        for key, group_id, values_seen in annotation_results:
            annotation_counts[key][group_id] = values_seen

        for g in objects:
            g.is_bookmarked = g.pk in bookmarks
            active_date = g.active_at or g.last_seen
            g.has_seen = seen_groups.get(g.id, active_date) > active_date
            g.annotations = []
            for key in sorted(tag_keys):
                if key in project_annotations[project]:
                    label = TAG_LABELS.get(key, key.replace('_', ' ')).lower() + 's'
                    try:
                        value = annotation_counts[key].get(g.id, 0)
                    except KeyError:
                        value = 0
                    g.annotations.append({
                        'label': label,
                        'count': value,
                    })
开发者ID:PostPCEra,项目名称:sentry,代码行数:54,代码来源:group.py

示例5: __init__

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def __init__(self, project, tag_list, *args, **kwargs):
        self.project = project
        super(ProjectTagsForm, self).__init__(*args, **kwargs)

        tag_choices = []
        for tag in tag_list:
            tag_choices.append(
                (tag, TAG_LABELS.get(tag) or tag.replace(u'_', u' ').title())
            )

        for field in ('filters', 'annotations'):
            self.fields[field].choices = tag_choices
            self.fields[field].widget.choices = self.fields[field].choices

        enabled_filters = ProjectOption.objects.get_value(
            self.project, 'tags', tag_list)
        self.fields['filters'].initial = enabled_filters

        enable_annotations = ProjectOption.objects.get_value(
            self.project, 'annotations', ['sentry:user'])
        self.fields['annotations'].initial = enable_annotations
开发者ID:Superdense,项目名称:sentry,代码行数:23,代码来源:projects.py

示例6: get_filters

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
def get_filters(project, request):
    filter_list = []

    for class_path in settings.SENTRY_FILTERS:
        try:
            filter_cls = import_string(class_path)
        except Exception:
            logger = logging.getLogger('sentry.errors')
            logger.exception('Unable to import %s', class_path)
            continue
        filter_list.append(filter_cls(request, project))

    for tag in project.get_tags():
        filter_list.append(Filter(
            column=tag,
            label=TAG_LABELS.get(tag) or tag.replace('_', ' ').title(),
            request=request,
            project=project,
        ))

    return filter_list
开发者ID:BlueMoebius,项目名称:sentry,代码行数:23,代码来源:sentry_stream_filters.py

示例7: get_label

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
 def get_label(self):
     return self.label \
         or TAG_LABELS.get(self.key) \
         or self.key.replace('_', ' ').title()
开发者ID:ChadKillingsworth,项目名称:sentry,代码行数:6,代码来源:tagkey.py

示例8: get_attrs

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def get_attrs(self, item_list, user):
        attach_foreignkey(item_list, Group.project, ['team'])

        if user.is_authenticated() and item_list:
            bookmarks = set(GroupBookmark.objects.filter(
                user=user,
                group__in=item_list,
            ).values_list('group_id', flat=True))
            seen_groups = dict(GroupSeen.objects.filter(
                user=user,
                group__in=item_list,
            ).values_list('group_id', 'last_seen'))
        else:
            bookmarks = set()
            seen_groups = {}

        tag_counts = defaultdict(dict)
        tag_results = GroupTagKey.objects.filter(
            group__in=item_list,
        ).values_list('key', 'group', 'values_seen')
        for key, group_id, values_seen in tag_results:
            tag_counts[key][group_id] = values_seen

        # we need to compute stats at 1d (1h resolution), and 14d/30d (1 day res)
        group_ids = [g.id for g in item_list]
        now = timezone.now()
        hourly_stats = tsdb.get_range(
            model=tsdb.models.group,
            keys=group_ids,
            end=now,
            start=now - timedelta(days=1),
            rollup=3600,
        )
        daily_stats = tsdb.get_range(
            model=tsdb.models.group,
            keys=group_ids,
            end=now,
            start=now - timedelta(days=30),
            rollup=3600 * 24,
        )

        result = {}
        for item in item_list:
            active_date = item.active_at or item.last_seen

            tags = {}
            for key in tag_counts.iterkeys():
                label = TAG_LABELS.get(key, key.replace('_', ' ')).lower()
                try:
                    value = tag_counts[key].get(item.id, 0)
                except KeyError:
                    value = 0
                tags[key] = {
                    'label': label,
                    'count': value,
                }

            result[item] = {
                'is_bookmarked': item.id in bookmarks,
                'has_seen': seen_groups.get(item.id, active_date) > active_date,
                'tags': tags,
                'hourly_stats': hourly_stats[item.id],
                'daily_stats': daily_stats[item.id],
            }
        return result
开发者ID:Juraldinio,项目名称:sentry,代码行数:67,代码来源:group.py

示例9: attach_metadata

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def attach_metadata(self, objects, request=None):
        from sentry.templatetags.sentry_plugins import handle_before_events

        attach_foreignkey(objects, Group.project, ['team'])

        GroupMeta.objects.populate_cache(objects)

        if request and objects:
            handle_before_events(request, objects)

        if request and request.user.is_authenticated() and objects:
            bookmarks = set(GroupBookmark.objects.filter(
                user=request.user,
                group__in=objects,
            ).values_list('group_id', flat=True))
            seen_groups = dict(GroupSeen.objects.filter(
                user=request.user,
                group__in=objects,
            ).values_list('group_id', 'last_seen'))
        else:
            bookmarks = set()
            seen_groups = {}

        if objects:
            end = timezone.now()
            start = end - timedelta(days=1)

            historical_data = tsdb.get_range(
                model=tsdb.models.group,
                keys=[g.id for g in objects],
                start=start,
                end=end,
            )
        else:
            historical_data = {}

        project_list = set(o.project for o in objects)
        tag_keys = set(['sentry:user'])
        project_annotations = {}
        for project in project_list:
            enabled_annotations = ProjectOption.objects.get_value(
                project, 'annotations', ['sentry:user'])
            project_annotations[project] = enabled_annotations
            tag_keys.update(enabled_annotations)

        annotation_counts = defaultdict(dict)
        annotation_results = GroupTagKey.objects.filter(
            group__in=objects,
            key__in=tag_keys,
        ).values_list('key', 'group', 'values_seen')
        for key, group_id, values_seen in annotation_results:
            annotation_counts[key][group_id] = values_seen

        for g in objects:
            g.is_bookmarked = g.pk in bookmarks
            g.historical_data = [x[1] for x in historical_data.get(g.id, [])]
            active_date = g.active_at or g.last_seen
            g.has_seen = seen_groups.get(g.id, active_date) > active_date
            g.annotations = []
            for key in sorted(tag_keys):
                if key in project_annotations[project]:
                    label = TAG_LABELS.get(key, key.replace('_', ' ')).lower() + 's'
                    try:
                        value = annotation_counts[key].get(g.id, 0)
                    except KeyError:
                        value = 0
                    g.annotations.append({
                        'label': label,
                        'count': value,
                    })
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:72,代码来源:javascript.py

示例10: get_tag_key_label

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
 def get_tag_key_label(self, key):
     return TAG_LABELS.get(key) or key.replace('_', ' ').title()
开发者ID:Kayle009,项目名称:sentry,代码行数:4,代码来源:base.py

示例11: get_label

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
 def get_label(self):
     return self.label or TAG_LABELS.get(self.key) or self.key.replace("_", " ").title()
开发者ID:ForkRepo,项目名称:sentry,代码行数:4,代码来源:tagkey.py

示例12: get_attrs

# 需要导入模块: from sentry.constants import TAG_LABELS [as 别名]
# 或者: from sentry.constants.TAG_LABELS import get [as 别名]
    def get_attrs(self, item_list, user):
        from sentry.plugins import plugins

        GroupMeta.objects.populate_cache(item_list)

        attach_foreignkey(item_list, Group.project, ['team'])

        if user.is_authenticated() and item_list:
            bookmarks = set(GroupBookmark.objects.filter(
                user=user,
                group__in=item_list,
            ).values_list('group_id', flat=True))
            seen_groups = dict(GroupSeen.objects.filter(
                user=user,
                group__in=item_list,
            ).values_list('group_id', 'last_seen'))
        else:
            bookmarks = set()
            seen_groups = {}

        tag_counts = defaultdict(dict)
        tag_results = GroupTagKey.objects.filter(
            group__in=item_list,
        ).values_list('key', 'group', 'values_seen')
        for key, group_id, values_seen in tag_results:
            tag_counts[key][group_id] = values_seen

        assignees = dict(
            (a.group_id, a.user)
            for a in GroupAssignee.objects.filter(
                group__in=item_list,
            ).select_related('user')
        )

        result = {}
        for item in item_list:
            active_date = item.active_at or item.last_seen

            tags = {}
            for key in tag_counts.iterkeys():
                label = TAG_LABELS.get(key, key.replace('_', ' ')).lower()
                try:
                    value = tag_counts[key].get(item.id, 0)
                except KeyError:
                    value = 0
                tags[key] = {
                    'label': label,
                    'count': value,
                }

            annotations = []
            for plugin in plugins.for_project(project=item.project, version=1):
                safe_execute(plugin.tags, None, item, annotations)
            for plugin in plugins.for_project(project=item.project, version=2):
                annotations.extend(safe_execute(plugin.get_annotations, item) or ())

            result[item] = {
                'assigned_to': serialize(assignees.get(item.id)),
                'is_bookmarked': item.id in bookmarks,
                'has_seen': seen_groups.get(item.id, active_date) > active_date,
                'tags': tags,
                'annotations': annotations,
            }
        return result
开发者ID:CBEPX,项目名称:sentry,代码行数:66,代码来源:group.py


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