Merge lp:~brian-murray/errors/bug-to-crash-sig into lp:errors

Proposed by Brian Murray
Status: Merged
Merged at revision: 379
Proposed branch: lp:~brian-murray/errors/bug-to-crash-sig
Merge into: lp:errors
Diff against target: 65 lines (+27/-1)
3 files modified
errors/api/resources.py (+14/-0)
errors/api/urls.py (+3/-1)
errors/cassandra.py (+10/-0)
To merge this branch: bzr merge lp:~brian-murray/errors/bug-to-crash-sig
Reviewer Review Type Date Requested Status
Evan (community) Approve
Review via email: mp+155877@code.launchpad.net

Description of the change

This is based on Evan's initial work for this and provides an API way to find crash signatures associated with a bug report.

To post a comment you must log in.
Revision history for this message
Evan (ev) wrote :

get_signatures_for_bug should return an empty list on failure, otherwise the code in resources.py will try to do a slice on None.

Otherwise this looks good. Feel free to merge it in with that change.

review: Approve
380. By Brian Murray

return an empty list if no crash signatures are found

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'errors/api/resources.py'
2--- errors/api/resources.py 2013-03-12 19:18:22 +0000
3+++ errors/api/resources.py 2013-03-28 16:20:27 +0000
4@@ -558,3 +558,17 @@
5 'derivatives': -1,
6 'total': total_total})
7 return wrapped()
8+
9+
10+class CrashSignaturesForBug(ErrorsResource):
11+ signatures = fields.ListField(attribute='signatures', readonly=True)
12+
13+ class Meta(ErrorsMeta):
14+ resource_name = 'crash-signatures-for-bug'
15+ def obj_get_list(self, request):
16+ bug = request.GET.get('bug', None)
17+ class wrapped(list):
18+ def __getslice__(self, start, finish):
19+ results = cassandra.get_signatures_for_bug(bug)
20+ return results[start:finish]
21+ return wrapped()
22
23=== modified file 'errors/api/urls.py'
24--- errors/api/urls.py 2013-03-08 21:52:59 +0000
25+++ errors/api/urls.py 2013-03-28 16:20:27 +0000
26@@ -15,7 +15,8 @@
27 AverageInstancesResource,
28 InstancesResource,
29 VersionsResource,
30- PackageVersionIsMostRecent)
31+ PackageVersionIsMostRecent,
32+ CrashSignaturesForBug)
33
34 v1_api = Api(api_name='1.0')
35 v1_api.register(RetraceResultResource())
36@@ -34,6 +35,7 @@
37 v1_api.register(AverageInstancesResource())
38 v1_api.register(InstancesResource())
39 v1_api.register(VersionsResource())
40+v1_api.register(CrashSignaturesForBug())
41
42 urlpatterns = patterns('',
43 url(r'^', include(v1_api.urls)),
44
45=== modified file 'errors/cassandra.py'
46--- errors/cassandra.py 2013-03-27 22:04:22 +0000
47+++ errors/cassandra.py 2013-03-28 16:20:27 +0000
48@@ -469,7 +469,17 @@
49
50 def record_bug_for_bucket(bucketid, bug):
51 bucketmetadata_cf = pycassa.ColumnFamily(pool, 'BucketMetadata')
52+ bugtocrashsignatures_cf = pycassa.ColumnFamily(pool, 'BugToCrashSignatures')
53 # We don't insert bugs into the database if we're using Launchpad staging,
54 # as those will disappear in Launchpad but our copy would persist.
55 if not config.lp_use_staging:
56 bucketmetadata_cf.insert(bucketid, {'CreatedBug' : bug})
57+ bugtocrashsignatures_cf.insert(bug, {bucketid: ''})
58+
59+def get_signatures_for_bug(bug):
60+ bugtocrashsignatures_cf = pycassa.ColumnFamily(pool, 'BugToCrashSignatures')
61+ try:
62+ crashes = [crash for crash in bugtocrashsignatures_cf.xget(bug)]
63+ return crashes
64+ except NotFoundException:
65+ return []

Subscribers

People subscribed via source and target branches

to all changes: