本文整理汇总了Python中sentry.utils.db.attach_foreignkey函数的典型用法代码示例。如果您正苦于以下问题:Python attach_foreignkey函数的具体用法?Python attach_foreignkey怎么用?Python attach_foreignkey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了attach_foreignkey函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: attach_metadata
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))
else:
bookmarks = set()
if objects:
historical_data = Group.objects.get_chart_data_for_group(
instances=objects,
max_days=1,
key='group',
)
else:
historical_data = {}
for g in objects:
g.is_bookmarked = g.pk in bookmarks
g.historical_data = [x[1] for x in historical_data.get(g.id, [])]
开发者ID:Aaron1011,项目名称:sentry,代码行数:28,代码来源:javascript.py
示例2: get_attrs
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 = {}
assignees = dict(
(a.group_id, a.user)
for a in GroupAssignee.objects.filter(
group__in=item_list,
).select_related('user')
)
user_counts = dict(
GroupTagKey.objects.filter(
group__in=item_list,
key='sentry:user',
).values_list('group', 'values_seen')
)
snoozes = dict(
GroupSnooze.objects.filter(
group__in=item_list,
).values_list('group', 'until')
)
result = {}
for item in item_list:
active_date = item.active_at or item.last_seen
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, group=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,
'annotations': annotations,
'user_count': user_counts.get(item.id, 0),
'snooze': snoozes.get(item.id),
}
return result
开发者ID:jonashaag,项目名称:sentry,代码行数:59,代码来源:group.py
示例3: get_attrs
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,代码行数:54,代码来源:group.py
示例4: attach_metadata
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,代码行数:53,代码来源:javascript.py
示例5: get_attrs
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,代码行数:53,代码来源:group.py
示例6: attach_metadata
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,代码行数:52,代码来源:group.py
示例7: attach_metadata
def attach_metadata(self, objects, user):
team_map = dict(
(t.id, t) for t in Team.objects.get_for_user(user).itervalues()
)
for project in objects:
try:
team = team_map[project.team_id]
project.access_type = team.access_type
project.team = team
except KeyError:
project.access_type = None
attach_foreignkey(objects, Project.team)
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:13,代码来源:project.py
示例8: attach_metadata
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 = {}
user_counts = dict(GroupTagKey.objects.filter(
group__in=objects,
key='sentry:user',
).values_list('group', '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, [])]
if user_counts:
g.users_seen = user_counts.get(g.id, 0)
active_date = g.active_at or g.last_seen
g.has_seen = seen_groups.get(g.id, active_date) > active_date
开发者ID:SmashingDevelopment,项目名称:sentry,代码行数:42,代码来源:javascript.py
示例9: get_for_user
def get_for_user(self, user=None, access=None, hidden=False, team=None,
superuser=True):
"""
Returns a SortedDict of all projects a user has some level of access to.
"""
from sentry.models import Team
if not (user and user.is_authenticated()):
return []
# TODO: the result of this function should be cached
is_authenticated = (user and user.is_authenticated())
base_qs = self
if not hidden:
base_qs = base_qs.filter(status=0)
if team:
base_qs = base_qs.filter(team=team)
if team and user.is_superuser and superuser:
projects = set(base_qs)
else:
projects_qs = base_qs
if not settings.SENTRY_PUBLIC:
# If the user is authenticated, include their memberships
teams = Team.objects.get_for_user(
user, access, access_groups=False).values()
if not teams:
projects_qs = self.none()
if team and team not in teams:
projects_qs = self.none()
elif not team:
projects_qs = projects_qs.filter(team__in=teams)
projects = set(projects_qs)
if is_authenticated:
projects |= set(base_qs.filter(accessgroup__members=user))
attach_foreignkey(projects, self.model.team)
return sorted(projects, key=lambda x: x.name.lower())
开发者ID:Tug,项目名称:sentry,代码行数:42,代码来源:manager.py
示例10: attach_metadata
def attach_metadata(self, objects, user):
if not objects:
return
organization = objects[0].team.organization
team_map = dict(
(t.id, t) for t in Team.objects.get_for_user(
organization=organization,
user=user,
)
)
for project in objects:
try:
team = team_map[project.team_id]
project.access_type = team.access_type
project.team = team
except KeyError:
project.access_type = None
attach_foreignkey(objects, Project.team)
开发者ID:PostPCEra,项目名称:sentry,代码行数:22,代码来源:project.py
示例11: get_attrs
def get_attrs(self, item_list, user):
from sentry.plugins import plugins
GroupMeta.objects.populate_cache(item_list)
attach_foreignkey(item_list, Group.project)
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')
)
subscriptions = self._get_subscriptions(item_list, user)
else:
bookmarks = set()
seen_groups = {}
subscriptions = defaultdict(lambda: (False, None))
assignees = dict(
(a.group_id, a.user)
for a in GroupAssignee.objects.filter(
group__in=item_list,
).select_related('user')
)
user_counts = tagstore.get_group_values_seen([g.id for g in item_list], 'sentry:user')
ignore_items = {g.group_id: g for g in GroupSnooze.objects.filter(
group__in=item_list,
)}
resolutions = {
i[0]: i[1:]
for i in GroupResolution.objects.filter(
group__in=item_list,
).values_list(
'group',
'type',
'release__version',
'actor_id',
)
}
actor_ids = set(r[-1] for r in six.itervalues(resolutions))
actor_ids.update(r.actor_id for r in six.itervalues(ignore_items))
if actor_ids:
users = list(User.objects.filter(
id__in=actor_ids,
is_active=True,
))
actors = {u.id: d for u, d in itertools.izip(users, serialize(users, user))}
else:
actors = {}
share_ids = dict(GroupShare.objects.filter(
group__in=item_list,
).values_list('group_id', 'uuid'))
result = {}
for item in item_list:
active_date = item.active_at or item.first_seen
annotations = []
for plugin in plugins.for_project(project=item.project, version=1):
safe_execute(plugin.tags, None, item, annotations, _with_transaction=False)
for plugin in plugins.for_project(project=item.project, version=2):
annotations.extend(
safe_execute(plugin.get_annotations, group=item, _with_transaction=False) or ()
)
resolution = resolutions.get(item.id)
if resolution:
resolution_actor = actors.get(resolution[-1])
else:
resolution_actor = None
ignore_item = ignore_items.get(item.id)
if ignore_item:
ignore_actor = actors.get(ignore_item.actor_id)
else:
ignore_actor = None
result[item] = {
'assigned_to': serialize(assignees.get(item.id)),
'is_bookmarked': item.id in bookmarks,
'subscription': subscriptions[item.id],
'has_seen': seen_groups.get(item.id, active_date) > active_date,
'annotations': annotations,
'user_count': user_counts.get(item.id, 0),
'ignore_until': ignore_item,
'ignore_actor': ignore_actor,
'resolution': resolution,
'resolution_actor': resolution_actor,
#.........这里部分代码省略.........
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:101,代码来源:group.py
示例12: get_attrs
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,代码行数:65,代码来源:group.py
示例13: attach_metadata
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,代码行数:70,代码来源:javascript.py
示例14: get_attrs
def get_attrs(self, item_list, user):
from sentry.plugins import plugins
GroupMeta.objects.populate_cache(item_list)
attach_foreignkey(item_list, Group.project)
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')
)
subscriptions = self._get_subscriptions(item_list, user)
else:
bookmarks = set()
seen_groups = {}
subscriptions = defaultdict(lambda: (False, None))
assignees = {
a.group_id: a.assigned_actor() for a in
GroupAssignee.objects.filter(
group__in=item_list,
)
}
resolved_assignees = Actor.resolve_dict(assignees)
ignore_items = {g.group_id: g for g in GroupSnooze.objects.filter(
group__in=item_list,
)}
resolved_item_list = [i for i in item_list if i.status == GroupStatus.RESOLVED]
if resolved_item_list:
release_resolutions = {
i[0]: i[1:]
for i in GroupResolution.objects.filter(
group__in=resolved_item_list,
).values_list(
'group',
'type',
'release__version',
'actor_id',
)
}
# due to our laziness, and django's inability to do a reasonable join here
# we end up with two queries
commit_results = list(Commit.objects.extra(
select={
'group_id': 'sentry_grouplink.group_id',
},
tables=['sentry_grouplink'],
where=[
'sentry_grouplink.linked_id = sentry_commit.id',
'sentry_grouplink.group_id IN ({})'.format(
', '.join(six.text_type(i.id) for i in resolved_item_list)),
'sentry_grouplink.linked_type = %s',
'sentry_grouplink.relationship = %s',
],
params=[
int(GroupLink.LinkedType.commit),
int(GroupLink.Relationship.resolves),
]
))
commit_resolutions = {
i.group_id: d for i, d in itertools.izip(commit_results, serialize(commit_results, user))
}
else:
release_resolutions = {}
commit_resolutions = {}
actor_ids = set(r[-1] for r in six.itervalues(release_resolutions))
actor_ids.update(r.actor_id for r in six.itervalues(ignore_items))
if actor_ids:
users = list(User.objects.filter(
id__in=actor_ids,
is_active=True,
))
actors = {u.id: d for u, d in itertools.izip(users, serialize(users, user))}
else:
actors = {}
share_ids = dict(GroupShare.objects.filter(
group__in=item_list,
).values_list('group_id', 'uuid'))
result = {}
seen_stats = self._get_seen_stats(item_list, user)
for item in item_list:
active_date = item.active_at or item.first_seen
#.........这里部分代码省略.........
开发者ID:Kayle009,项目名称:sentry,代码行数:101,代码来源:group.py
示例15: get_attrs
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')
)
tagkeys = dict(
(t.key, t)
for t in TagKey.objects.filter(
project=item_list[0].project,
key__in=tag_counts.keys(),
)
)
result = {}
for item in item_list:
active_date = item.active_at or item.last_seen
# TODO(dcramer): switch to serializers
tags = {}
for key in tag_counts.iterkeys():
try:
tagkey = tagkeys[key]
except KeyError:
label = key.replace('_', ' ').title()
else:
if tagkey.status != TagKeyStatus.VISIBLE:
continue
label = tagkey.get_label()
try:
value = tag_counts[key].get(item.id, 0)
except KeyError:
value = 0
if key.startswith('sentry:'):
key = key.split('sentry:', 1)[-1]
tags[key] = {
'name': 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, group=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:Natim,项目名称:sentry,代码行数:85,代码来源:group.py
示例16: get_attrs
def get_attrs(self, item_list, user):
from sentry.plugins import plugins
GroupMeta.objects.populate_cache(item_list)
attach_foreignkey(item_list, Group.project)
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'))
subscriptions = self._get_subscriptions(item_list, user)
else:
bookmarks = set()
seen_groups = {}
subscriptions = defaultdict(lambda: (False, None))
assignees = dict(
(a.group_id, a.user)
for a in GroupAssignee.objects.filter(
group__in=item_list,
).select_related('user')
)
user_counts = dict(
GroupTagKey.objects.filter(
group__in=item_list,
key='sentry:user',
).values_list('group', 'values_seen')
)
ignore_durations = dict(
GroupSnooze.objects.filter(
group__in=item_list,
).values_list('group', 'until')
)
pending_resolutions = dict(
GroupResolution.objects.filter(
group__in=item_list,
status=GroupResolutionStatus.PENDING,
).values_list('group', 'release')
)
result = {}
for item in item_list:
active_date = item.active_at or item.first_seen
annotations = []
for plugin in plugins.for_project(project=item.project, version=1):
safe_execute(plugin.tags, None, item, annotations,
_with_transaction=False)
for plugin in plugins.for_project(project=item.project, version=2):
annotations.extend(safe_execute(plugin.get_annotations, group=item,
_with_transaction=False) or ())
result[item] = {
'assigned_to': serialize(assignees.get(item.id)),
'is_bookmarked': item.id in bookmarks,
'subscription': subscriptions[item.id],
'has_seen': seen_groups.get(item.id, active_date) > active_date,
'annotations': annotations,
'user_count': user_counts.get(item.id, 0),
'ignore_duration': ignore_durations.get(item.id),
'pending_resolution': pending_resolutions.get(item.id),
}
return result
开发者ID:sashahilton00,项目名称:sentry,代码行数:72,代码来源:group.py
示例17: get_attrs
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,代码行数:64,代码来源:group.py
注:本文中的sentry.utils.db.attach_foreignkey函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论