{"action":"created","comment":{"url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/comments/45604814","id":45604814,"diff_hunk":"@@ -0,0 +1,71 @@\n+from flask.ext.restful import marshal_with, fields\n+from flask import Blueprint as FlaskBlueprint\n+\n+import logging\n+\n+from pouta_blueprints.models import Blueprint, Instance\n+from pouta_blueprints.server import restful\n+from pouta_blueprints.views.commons import auth\n+from pouta_blueprints.utils import requires_admin, memoize\n+\n+from collections import defaultdict\n+\n+\n+stats = FlaskBlueprint('stats', __name__)\n+\n+\n+def query_blueprint(blueprint_id):\n+    return Blueprint.query.filter_by(id=blueprint_id).first()\n+\n+\n+blueprint_result_fields = {\n+\n+    'blueprint': {\n+        'name': fields.String,\n+        'users': fields.Integer,\n+        'launched_instances': fields.Integer,\n+        'running_instances': fields.Integer,\n+    },\n+    'overall_running_instances': fields.Integer\n+}\n+\n+\n+class StatsList(restful.Resource):\n+    @auth.login_required\n+    @requires_admin\n+    @marshal_with(blueprint_result_fields)\n+    def get(self):\n+        instances = Instance.query.all()\n+        overall_running_instances = Instance.query.filter(Instance.state != Instance.STATE_DELETED).count()","path":"pouta_blueprints/views/stats.py","position":39,"original_position":39,"commit_id":"1d299663417019b1f0dd236eda558e5c039c8a7d","original_commit_id":"1d299663417019b1f0dd236eda558e5c039c8a7d","user":{"login":"apurva3000","id":6124928,"avatar_url":"https://avatars.githubusercontent.com/u/6124928?v=3","gravatar_id":"","url":"https://api.github.com/users/apurva3000","html_url":"https://github.com/apurva3000","followers_url":"https://api.github.com/users/apurva3000/followers","following_url":"https://api.github.com/users/apurva3000/following{/other_user}","gists_url":"https://api.github.com/users/apurva3000/gists{/gist_id}","starred_url":"https://api.github.com/users/apurva3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apurva3000/subscriptions","organizations_url":"https://api.github.com/users/apurva3000/orgs","repos_url":"https://api.github.com/users/apurva3000/repos","events_url":"https://api.github.com/users/apurva3000/events{/privacy}","received_events_url":"https://api.github.com/users/apurva3000/received_events","type":"User","site_admin":false},"body":"Yes","created_at":"2015-11-23T13:57:17Z","updated_at":"2015-11-23T13:57:17Z","html_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints/pull/391#discussion_r45604814","pull_request_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391","_links":{"self":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/comments/45604814"},"html":{"href":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints/pull/391#discussion_r45604814"},"pull_request":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391"}}},"pull_request":{"url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391","id":51217923,"html_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints/pull/391","diff_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints/pull/391.diff","patch_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints/pull/391.patch","issue_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/391","number":391,"state":"open","locked":false,"title":"Feature/admin statistics#80","user":{"login":"apurva3000","id":6124928,"avatar_url":"https://avatars.githubusercontent.com/u/6124928?v=3","gravatar_id":"","url":"https://api.github.com/users/apurva3000","html_url":"https://github.com/apurva3000","followers_url":"https://api.github.com/users/apurva3000/followers","following_url":"https://api.github.com/users/apurva3000/following{/other_user}","gists_url":"https://api.github.com/users/apurva3000/gists{/gist_id}","starred_url":"https://api.github.com/users/apurva3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apurva3000/subscriptions","organizations_url":"https://api.github.com/users/apurva3000/orgs","repos_url":"https://api.github.com/users/apurva3000/repos","events_url":"https://api.github.com/users/apurva3000/events{/privacy}","received_events_url":"https://api.github.com/users/apurva3000/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-19T12:49:05Z","updated_at":"2015-11-23T13:57:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45902657d95bc6fdb3d310a640c9907a4ca864a1","assignee":{"login":"hhamalai","id":502173,"avatar_url":"https://avatars.githubusercontent.com/u/502173?v=3","gravatar_id":"","url":"https://api.github.com/users/hhamalai","html_url":"https://github.com/hhamalai","followers_url":"https://api.github.com/users/hhamalai/followers","following_url":"https://api.github.com/users/hhamalai/following{/other_user}","gists_url":"https://api.github.com/users/hhamalai/gists{/gist_id}","starred_url":"https://api.github.com/users/hhamalai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhamalai/subscriptions","organizations_url":"https://api.github.com/users/hhamalai/orgs","repos_url":"https://api.github.com/users/hhamalai/repos","events_url":"https://api.github.com/users/hhamalai/events{/privacy}","received_events_url":"https://api.github.com/users/hhamalai/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391/commits","review_comments_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391/comments","review_comment_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/391/comments","statuses_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/statuses/1d299663417019b1f0dd236eda558e5c039c8a7d","head":{"label":"CSC-IT-Center-for-Science:feature/admin_statistics#80","ref":"feature/admin_statistics#80","sha":"1d299663417019b1f0dd236eda558e5c039c8a7d","user":{"login":"CSC-IT-Center-for-Science","id":5947494,"avatar_url":"https://avatars.githubusercontent.com/u/5947494?v=3","gravatar_id":"","url":"https://api.github.com/users/CSC-IT-Center-for-Science","html_url":"https://github.com/CSC-IT-Center-for-Science","followers_url":"https://api.github.com/users/CSC-IT-Center-for-Science/followers","following_url":"https://api.github.com/users/CSC-IT-Center-for-Science/following{/other_user}","gists_url":"https://api.github.com/users/CSC-IT-Center-for-Science/gists{/gist_id}","starred_url":"https://api.github.com/users/CSC-IT-Center-for-Science/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CSC-IT-Center-for-Science/subscriptions","organizations_url":"https://api.github.com/users/CSC-IT-Center-for-Science/orgs","repos_url":"https://api.github.com/users/CSC-IT-Center-for-Science/repos","events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/events{/privacy}","received_events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/received_events","type":"Organization","site_admin":false},"repo":{"id":27765622,"name":"pouta-blueprints","full_name":"CSC-IT-Center-for-Science/pouta-blueprints","owner":{"login":"CSC-IT-Center-for-Science","id":5947494,"avatar_url":"https://avatars.githubusercontent.com/u/5947494?v=3","gravatar_id":"","url":"https://api.github.com/users/CSC-IT-Center-for-Science","html_url":"https://github.com/CSC-IT-Center-for-Science","followers_url":"https://api.github.com/users/CSC-IT-Center-for-Science/followers","following_url":"https://api.github.com/users/CSC-IT-Center-for-Science/following{/other_user}","gists_url":"https://api.github.com/users/CSC-IT-Center-for-Science/gists{/gist_id}","starred_url":"https://api.github.com/users/CSC-IT-Center-for-Science/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CSC-IT-Center-for-Science/subscriptions","organizations_url":"https://api.github.com/users/CSC-IT-Center-for-Science/orgs","repos_url":"https://api.github.com/users/CSC-IT-Center-for-Science/repos","events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/events{/privacy}","received_events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints","description":"Pouta Blueprints is a frontend to manage cloud resources and lightweight user accounts. ","fork":false,"url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints","forks_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/forks","keys_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/teams","hooks_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/hooks","issue_events_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/events{/number}","events_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/events","assignees_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/assignees{/user}","branches_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/branches{/branch}","tags_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/tags","blobs_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/refs{/sha}","trees_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/statuses/{sha}","languages_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/languages","stargazers_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/stargazers","contributors_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/contributors","subscribers_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/subscribers","subscription_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/subscription","commits_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/commits{/sha}","git_commits_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/commits{/sha}","comments_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/comments{/number}","issue_comment_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/comments{/number}","contents_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/contents/{+path}","compare_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/merges","archive_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/downloads","issues_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues{/number}","pulls_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls{/number}","milestones_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/milestones{/number}","notifications_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/labels{/name}","releases_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/releases{/id}","created_at":"2014-12-09T12:31:14Z","updated_at":"2015-09-17T09:39:14Z","pushed_at":"2015-11-23T13:45:09Z","git_url":"git://github.com/CSC-IT-Center-for-Science/pouta-blueprints.git","ssh_url":"git@github.com:CSC-IT-Center-for-Science/pouta-blueprints.git","clone_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints.git","svn_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints","homepage":"","size":1579,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"base":{"label":"CSC-IT-Center-for-Science:master","ref":"master","sha":"05b085c3e3df5a101211e632e27a70b48f859497","user":{"login":"CSC-IT-Center-for-Science","id":5947494,"avatar_url":"https://avatars.githubusercontent.com/u/5947494?v=3","gravatar_id":"","url":"https://api.github.com/users/CSC-IT-Center-for-Science","html_url":"https://github.com/CSC-IT-Center-for-Science","followers_url":"https://api.github.com/users/CSC-IT-Center-for-Science/followers","following_url":"https://api.github.com/users/CSC-IT-Center-for-Science/following{/other_user}","gists_url":"https://api.github.com/users/CSC-IT-Center-for-Science/gists{/gist_id}","starred_url":"https://api.github.com/users/CSC-IT-Center-for-Science/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CSC-IT-Center-for-Science/subscriptions","organizations_url":"https://api.github.com/users/CSC-IT-Center-for-Science/orgs","repos_url":"https://api.github.com/users/CSC-IT-Center-for-Science/repos","events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/events{/privacy}","received_events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/received_events","type":"Organization","site_admin":false},"repo":{"id":27765622,"name":"pouta-blueprints","full_name":"CSC-IT-Center-for-Science/pouta-blueprints","owner":{"login":"CSC-IT-Center-for-Science","id":5947494,"avatar_url":"https://avatars.githubusercontent.com/u/5947494?v=3","gravatar_id":"","url":"https://api.github.com/users/CSC-IT-Center-for-Science","html_url":"https://github.com/CSC-IT-Center-for-Science","followers_url":"https://api.github.com/users/CSC-IT-Center-for-Science/followers","following_url":"https://api.github.com/users/CSC-IT-Center-for-Science/following{/other_user}","gists_url":"https://api.github.com/users/CSC-IT-Center-for-Science/gists{/gist_id}","starred_url":"https://api.github.com/users/CSC-IT-Center-for-Science/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CSC-IT-Center-for-Science/subscriptions","organizations_url":"https://api.github.com/users/CSC-IT-Center-for-Science/orgs","repos_url":"https://api.github.com/users/CSC-IT-Center-for-Science/repos","events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/events{/privacy}","received_events_url":"https://api.github.com/users/CSC-IT-Center-for-Science/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints","description":"Pouta Blueprints is a frontend to manage cloud resources and lightweight user accounts. ","fork":false,"url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints","forks_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/forks","keys_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/teams","hooks_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/hooks","issue_events_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/events{/number}","events_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/events","assignees_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/assignees{/user}","branches_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/branches{/branch}","tags_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/tags","blobs_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/refs{/sha}","trees_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/statuses/{sha}","languages_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/languages","stargazers_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/stargazers","contributors_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/contributors","subscribers_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/subscribers","subscription_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/subscription","commits_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/commits{/sha}","git_commits_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/git/commits{/sha}","comments_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/comments{/number}","issue_comment_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/comments{/number}","contents_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/contents/{+path}","compare_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/merges","archive_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/downloads","issues_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues{/number}","pulls_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls{/number}","milestones_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/milestones{/number}","notifications_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/labels{/name}","releases_url":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/releases{/id}","created_at":"2014-12-09T12:31:14Z","updated_at":"2015-09-17T09:39:14Z","pushed_at":"2015-11-23T13:45:09Z","git_url":"git://github.com/CSC-IT-Center-for-Science/pouta-blueprints.git","ssh_url":"git@github.com:CSC-IT-Center-for-Science/pouta-blueprints.git","clone_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints.git","svn_url":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints","homepage":"","size":1579,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391"},"html":{"href":"https://github.com/CSC-IT-Center-for-Science/pouta-blueprints/pull/391"},"issue":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/391"},"comments":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/issues/391/comments"},"review_comments":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391/comments"},"review_comment":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/pulls/391/commits"},"statuses":{"href":"https://api.github.com/repos/CSC-IT-Center-for-Science/pouta-blueprints/statuses/1d299663417019b1f0dd236eda558e5c039c8a7d"}}}}