{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/treeherder/pulls/comments/36970874","id":36970874,"diff_hunk":"@@ -2,16 +2,82 @@\n # License, v. 2.0. If a copy of the MPL was not distributed with this\n # file, you can obtain one at http://mozilla.org/MPL/2.0/.\n \n+import json\n+import time\n+\n from django.core.cache import cache\n from rest_framework import viewsets\n from rest_framework.response import Response\n from rest_framework.decorators import list_route\n from rest_framework_extensions.etag.decorators import etag\n \n-\n+from treeherder.model import models\n from treeherder.model.derived.jobs import JobsModel\n from treeherder.webapp.api.utils import (with_jobs)\n+from treeherder.webapp.api import serializers as th_serializers\n+\n+\n+class PerformanceSignatureViewSet(viewsets.ViewSet):\n+\n+    def list(self, request, project):\n+\n+        repository = models.Repository.objects.get(name=project)\n+\n+        # TODO: support other parameters like interval, etc\n+\n+        signature_data = models.PerformanceDatum.objects.filter(\n+            repository=repository).select_related(\n+                'signature', 'signature__option_collection',\n+                'signature__platform').values_list(\n+                    'signature__uuid',\n+                    'signature__option_collection__option_collection_hash',\n+                    'signature__platform__platform', 'signature__suite',\n+                    'signature__test', 'signature__extra_properties').distinct()\n+\n+        ret = {}\n+        for (uuid, option_collection_hash, platform, suite, test,\n+             extra_properties) in signature_data:\n+            ret[uuid] = {\n+                'option_collection_hash': option_collection_hash,\n+                'machine_platform': platform,\n+                'suite': suite,\n+                'test': test,\n+            }\n+            ret[uuid].update(json.loads(extra_properties))\n+\n+        return Response(ret)\n+\n+class PerformanceDatumViewSet(viewsets.ViewSet):\n+\n+    def list(self, request, project):\n+        repository = models.Repository.objects.get(name=project)\n+\n+        try:\n+            signatures = request.QUERY_PARAMS.getlist(\"signatures\")\n+        except Exception:\n+            return Response(\"incorrect parameters\", 400)\n \n+        # TODO: support other parameters like interval, etc\n+\n+        # FIXME: could we make this more efficient by using a serializer?\n+        ret = {}\n+        for signature in signatures:\n+            signature_obj = models.PerformanceSignature.objects.get(uuid=signature)\n+            datums = models.PerformanceDatum.objects.filter(repository=repository,","path":"treeherder/webapp/api/performance_data.py","position":66,"original_position":66,"commit_id":"e8d1b7abf3a1b0864ca3260fb9110ceb516d8f73","original_commit_id":"e8d1b7abf3a1b0864ca3260fb9110ceb516d8f73","user":{"login":"maurodoglio","id":508377,"avatar_url":"https://avatars.githubusercontent.com/u/508377?v=3","gravatar_id":"","url":"https://api.github.com/users/maurodoglio","html_url":"https://github.com/maurodoglio","followers_url":"https://api.github.com/users/maurodoglio/followers","following_url":"https://api.github.com/users/maurodoglio/following{/other_user}","gists_url":"https://api.github.com/users/maurodoglio/gists{/gist_id}","starred_url":"https://api.github.com/users/maurodoglio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maurodoglio/subscriptions","organizations_url":"https://api.github.com/users/maurodoglio/orgs","repos_url":"https://api.github.com/users/maurodoglio/repos","events_url":"https://api.github.com/users/maurodoglio/events{/privacy}","received_events_url":"https://api.github.com/users/maurodoglio/received_events","type":"User","site_admin":false},"body":"This will generate 2 queries per signature, which is probably too much.\r\nYou can obtain more or less the same with\r\n```python\r\ndatum_list = models.PerformanceDatum.objects.filter(repository=repository, signature__uuid__in=signatures).order_by('signature__uuid', 'push_timestamp')\r\n```","created_at":"2015-08-13T13:01:49Z","updated_at":"2015-08-13T13:01:49Z","html_url":"https://github.com/mozilla/treeherder/pull/870#discussion_r36970874","pull_request_url":"https://api.github.com/repos/mozilla/treeherder/pulls/870","_links":{"self":{"href":"https://api.github.com/repos/mozilla/treeherder/pulls/comments/36970874"},"html":{"href":"https://github.com/mozilla/treeherder/pull/870#discussion_r36970874"},"pull_request":{"href":"https://api.github.com/repos/mozilla/treeherder/pulls/870"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/treeherder/pulls/870","id":42298333,"html_url":"https://github.com/mozilla/treeherder/pull/870","diff_url":"https://github.com/mozilla/treeherder/pull/870.diff","patch_url":"https://github.com/mozilla/treeherder/pull/870.patch","issue_url":"https://api.github.com/repos/mozilla/treeherder/issues/870","number":870,"state":"open","locked":false,"title":"First pass at using django ORM for storing perf data DO NOT MERGE","user":{"login":"wlach","id":20569,"avatar_url":"https://avatars.githubusercontent.com/u/20569?v=3","gravatar_id":"","url":"https://api.github.com/users/wlach","html_url":"https://github.com/wlach","followers_url":"https://api.github.com/users/wlach/followers","following_url":"https://api.github.com/users/wlach/following{/other_user}","gists_url":"https://api.github.com/users/wlach/gists{/gist_id}","starred_url":"https://api.github.com/users/wlach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlach/subscriptions","organizations_url":"https://api.github.com/users/wlach/orgs","repos_url":"https://api.github.com/users/wlach/repos","events_url":"https://api.github.com/users/wlach/events{/privacy}","received_events_url":"https://api.github.com/users/wlach/received_events","type":"User","site_admin":false},"body":"\n\n<!-- Reviewable:start -->\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/mozilla/treeherder/870)\n<!-- Reviewable:end -->\n","created_at":"2015-08-12T22:49:35Z","updated_at":"2015-08-13T13:01:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/treeherder/pulls/870/commits","review_comments_url":"https://api.github.com/repos/mozilla/treeherder/pulls/870/comments","review_comment_url":"https://api.github.com/repos/mozilla/treeherder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/treeherder/issues/870/comments","statuses_url":"https://api.github.com/repos/mozilla/treeherder/statuses/e8d1b7abf3a1b0864ca3260fb9110ceb516d8f73","head":{"label":"wlach:1192976","ref":"1192976","sha":"e8d1b7abf3a1b0864ca3260fb9110ceb516d8f73","user":{"login":"wlach","id":20569,"avatar_url":"https://avatars.githubusercontent.com/u/20569?v=3","gravatar_id":"","url":"https://api.github.com/users/wlach","html_url":"https://github.com/wlach","followers_url":"https://api.github.com/users/wlach/followers","following_url":"https://api.github.com/users/wlach/following{/other_user}","gists_url":"https://api.github.com/users/wlach/gists{/gist_id}","starred_url":"https://api.github.com/users/wlach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlach/subscriptions","organizations_url":"https://api.github.com/users/wlach/orgs","repos_url":"https://api.github.com/users/wlach/repos","events_url":"https://api.github.com/users/wlach/events{/privacy}","received_events_url":"https://api.github.com/users/wlach/received_events","type":"User","site_admin":false},"repo":{"id":25893449,"name":"treeherder","full_name":"wlach/treeherder","owner":{"login":"wlach","id":20569,"avatar_url":"https://avatars.githubusercontent.com/u/20569?v=3","gravatar_id":"","url":"https://api.github.com/users/wlach","html_url":"https://github.com/wlach","followers_url":"https://api.github.com/users/wlach/followers","following_url":"https://api.github.com/users/wlach/following{/other_user}","gists_url":"https://api.github.com/users/wlach/gists{/gist_id}","starred_url":"https://api.github.com/users/wlach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlach/subscriptions","organizations_url":"https://api.github.com/users/wlach/orgs","repos_url":"https://api.github.com/users/wlach/repos","events_url":"https://api.github.com/users/wlach/events{/privacy}","received_events_url":"https://api.github.com/users/wlach/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wlach/treeherder","description":"The backend of treeherder, a replacement for TBPL. See wiki page for where to file bugs.","fork":true,"url":"https://api.github.com/repos/wlach/treeherder","forks_url":"https://api.github.com/repos/wlach/treeherder/forks","keys_url":"https://api.github.com/repos/wlach/treeherder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wlach/treeherder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wlach/treeherder/teams","hooks_url":"https://api.github.com/repos/wlach/treeherder/hooks","issue_events_url":"https://api.github.com/repos/wlach/treeherder/issues/events{/number}","events_url":"https://api.github.com/repos/wlach/treeherder/events","assignees_url":"https://api.github.com/repos/wlach/treeherder/assignees{/user}","branches_url":"https://api.github.com/repos/wlach/treeherder/branches{/branch}","tags_url":"https://api.github.com/repos/wlach/treeherder/tags","blobs_url":"https://api.github.com/repos/wlach/treeherder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wlach/treeherder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wlach/treeherder/git/refs{/sha}","trees_url":"https://api.github.com/repos/wlach/treeherder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wlach/treeherder/statuses/{sha}","languages_url":"https://api.github.com/repos/wlach/treeherder/languages","stargazers_url":"https://api.github.com/repos/wlach/treeherder/stargazers","contributors_url":"https://api.github.com/repos/wlach/treeherder/contributors","subscribers_url":"https://api.github.com/repos/wlach/treeherder/subscribers","subscription_url":"https://api.github.com/repos/wlach/treeherder/subscription","commits_url":"https://api.github.com/repos/wlach/treeherder/commits{/sha}","git_commits_url":"https://api.github.com/repos/wlach/treeherder/git/commits{/sha}","comments_url":"https://api.github.com/repos/wlach/treeherder/comments{/number}","issue_comment_url":"https://api.github.com/repos/wlach/treeherder/issues/comments{/number}","contents_url":"https://api.github.com/repos/wlach/treeherder/contents/{+path}","compare_url":"https://api.github.com/repos/wlach/treeherder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wlach/treeherder/merges","archive_url":"https://api.github.com/repos/wlach/treeherder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wlach/treeherder/downloads","issues_url":"https://api.github.com/repos/wlach/treeherder/issues{/number}","pulls_url":"https://api.github.com/repos/wlach/treeherder/pulls{/number}","milestones_url":"https://api.github.com/repos/wlach/treeherder/milestones{/number}","notifications_url":"https://api.github.com/repos/wlach/treeherder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wlach/treeherder/labels{/name}","releases_url":"https://api.github.com/repos/wlach/treeherder/releases{/id}","created_at":"2014-10-28T22:37:53Z","updated_at":"2015-04-29T20:36:16Z","pushed_at":"2015-08-12T22:48:54Z","git_url":"git://github.com/wlach/treeherder.git","ssh_url":"git@github.com:wlach/treeherder.git","clone_url":"https://github.com/wlach/treeherder.git","svn_url":"https://github.com/wlach/treeherder","homepage":"https://wiki.mozilla.org/Auto-tools/Projects/Treeherder","size":35485,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"aea08d418d43b3111e7603d4f7cc3f83d382f908","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":8463294,"name":"treeherder","full_name":"mozilla/treeherder","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/treeherder","description":"A reporting dashboard & service for managing CI data for commits to Mozilla projects","fork":false,"url":"https://api.github.com/repos/mozilla/treeherder","forks_url":"https://api.github.com/repos/mozilla/treeherder/forks","keys_url":"https://api.github.com/repos/mozilla/treeherder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/treeherder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/treeherder/teams","hooks_url":"https://api.github.com/repos/mozilla/treeherder/hooks","issue_events_url":"https://api.github.com/repos/mozilla/treeherder/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/treeherder/events","assignees_url":"https://api.github.com/repos/mozilla/treeherder/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/treeherder/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/treeherder/tags","blobs_url":"https://api.github.com/repos/mozilla/treeherder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/treeherder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/treeherder/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/treeherder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/treeherder/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/treeherder/languages","stargazers_url":"https://api.github.com/repos/mozilla/treeherder/stargazers","contributors_url":"https://api.github.com/repos/mozilla/treeherder/contributors","subscribers_url":"https://api.github.com/repos/mozilla/treeherder/subscribers","subscription_url":"https://api.github.com/repos/mozilla/treeherder/subscription","commits_url":"https://api.github.com/repos/mozilla/treeherder/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/treeherder/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/treeherder/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/treeherder/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/treeherder/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/treeherder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/treeherder/merges","archive_url":"https://api.github.com/repos/mozilla/treeherder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/treeherder/downloads","issues_url":"https://api.github.com/repos/mozilla/treeherder/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/treeherder/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/treeherder/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/treeherder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/treeherder/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/treeherder/releases{/id}","created_at":"2013-02-27T19:17:37Z","updated_at":"2015-07-02T05:58:54Z","pushed_at":"2015-08-13T10:45:53Z","git_url":"git://github.com/mozilla/treeherder.git","ssh_url":"git@github.com:mozilla/treeherder.git","clone_url":"https://github.com/mozilla/treeherder.git","svn_url":"https://github.com/mozilla/treeherder","homepage":"https://wiki.mozilla.org/Auto-tools/Projects/Treeherder","size":401151,"stargazers_count":25,"watchers_count":25,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":24,"forks":63,"open_issues":24,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/treeherder/pulls/870"},"html":{"href":"https://github.com/mozilla/treeherder/pull/870"},"issue":{"href":"https://api.github.com/repos/mozilla/treeherder/issues/870"},"comments":{"href":"https://api.github.com/repos/mozilla/treeherder/issues/870/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/treeherder/pulls/870/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/treeherder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/treeherder/pulls/870/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/treeherder/statuses/e8d1b7abf3a1b0864ca3260fb9110ceb516d8f73"}}}}