本文整理汇总了Python中sentry.models.Release.get_closest_releases方法的典型用法代码示例。如果您正苦于以下问题:Python Release.get_closest_releases方法的具体用法?Python Release.get_closest_releases怎么用?Python Release.get_closest_releases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.models.Release
的用法示例。
在下文中一共展示了Release.get_closest_releases方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple
# 需要导入模块: from sentry.models import Release [as 别名]
# 或者: from sentry.models.Release import get_closest_releases [as 别名]
def test_simple(self):
date = datetime.datetime.utcnow()
org = self.create_organization()
project = self.create_project(organization=org, name='foo')
# this shouldn't be included
release1 = Release.objects.create(
organization=org,
version='a' * 40,
date_released=date - datetime.timedelta(days=2),
)
release1.add_project(project)
release2 = Release.objects.create(
organization=org,
version='b' * 40,
date_released=date - datetime.timedelta(days=1),
)
release2.add_project(project)
release3 = Release.objects.create(
organization=org,
version='c' * 40,
date_released=date,
)
release3.add_project(project)
releases = list(Release.get_closest_releases(project, release2.version))
assert len(releases) == 2
assert releases[0] == release2
assert releases[1] == release3
示例2: get
# 需要导入模块: from sentry.models import Release [as 别名]
# 或者: from sentry.models.Release import get_closest_releases [as 别名]
def get(self, _, project, event_id):
"""
Retrieve Committer information for an event
```````````````````````````````````````````
Return commiters on an individual event, plus a per-frame breakdown.
:pparam string project_slug: the slug of the project the event
belongs to.
:pparam string event_id: the hexadecimal ID of the event to
retrieve (as reported by the raven client).
:auth: required
"""
try:
event = Event.objects.get(
id=event_id,
project_id=project.id,
)
except Event.DoesNotExist:
return Response({'detail': 'Event not found'}, status=404)
# populate event data
Event.objects.bind_nodes([event], 'data')
group = Group.objects.get(id=event.group_id)
first_release_version = group.get_first_release()
if not first_release_version:
return Response({'detail': 'Release not found'}, status=404)
releases = Release.get_closest_releases(project, first_release_version)
if not releases:
return Response({'detail': 'Release not found'}, status=404)
commits = self._get_commits(releases)
if not commits:
return Response({'detail': 'No Commits found for Release'}, status=404)
frames = self._get_frame_paths(event)
frame_limit = 15
app_frames = [frame for frame in frames if frame['in_app']][:frame_limit]
# TODO(maxbittker) return this set instead of annotated frames
path_set = {frame['abs_path'] for frame in app_frames}
file_changes = []
if path_set:
file_changes = self._get_commit_file_changes(commits, path_set)
commit_path_matches = {
path: self._match_commits_path(file_changes, path) for path in path_set
}
annotated_frames = [
{
'frame': frame,
'commits': commit_path_matches[frame['abs_path']]
} for frame in app_frames
]
relevant_commits = list(
{commit for match in commit_path_matches for commit in commit_path_matches[match]}
)
committers = self._get_committers(annotated_frames, relevant_commits)
# serialize the commit objects
serialized_annotated_frames = [
{
'frame': frame['frame'],
'commits': serialize(frame['commits'])
} for frame in annotated_frames
]
data = {
# map author ids to sentry user dicts
'committers': committers,
'annotatedFrames': serialized_annotated_frames
}
return Response(data)