{"action":"created","comment":{"url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/25581863","id":25581863,"diff_hunk":"@@ -0,0 +1,80 @@\n+#!/usr/bin/env python\n+# -*- coding: utf-8 -*-\n+\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+from __future__ import unicode_literals\n+\n+from django.conf import settings\n+from django.db.models import Sum\n+from django.template.defaultfilters import slugify\n+\n+from ralph_scrooge.rest.components import ComponentsContent\n+from ralph_scrooge.models import DailyCost, PricingObject\n+\n+\n+class PricingObjectsContent(ComponentsContent):\n+    \"\"\"A view returning pricing data per pricing object\"\"\"\n+\n+    default_model = 'ralph_scrooge.models.PricingObject'\n+\n+    def get_daily_pricing_objects(\n+            self, start_date, end_date, service, env=None\n+    ):\n+        query = PricingObject.objects.filter(\n+            daily_pricing_objects__service_environment__service__id=service,\n+            daily_pricing_objects__date__gte=start_date,\n+            daily_pricing_objects__date__lte=end_date,\n+        )\n+        if env:\n+            query = query.filter(\n+                daily_pricing_objects__service_environment__environment__id=env\n+            )\n+        pricing_object_ids = query.values_list('id', flat=True)\n+        query_daily_cost = DailyCost.objects.filter(\n+            pricing_object_id__in=pricing_object_ids,\n+            date__gte=start_date,\n+            date__lte=end_date,\n+            service_environment__service__id=service","path":"src/ralph_scrooge/rest/pricing_objects.py","position":39,"original_position":39,"commit_id":"d2bcaba82e3ed8d715991ecd0e7d0ed91b4bf260","original_commit_id":"d2bcaba82e3ed8d715991ecd0e7d0ed91b4bf260","user":{"login":"mkurek","id":107437,"avatar_url":"https://avatars.githubusercontent.com/u/107437?v=3","gravatar_id":"","url":"https://api.github.com/users/mkurek","html_url":"https://github.com/mkurek","followers_url":"https://api.github.com/users/mkurek/followers","following_url":"https://api.github.com/users/mkurek/following{/other_user}","gists_url":"https://api.github.com/users/mkurek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkurek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkurek/subscriptions","organizations_url":"https://api.github.com/users/mkurek/orgs","repos_url":"https://api.github.com/users/mkurek/repos","events_url":"https://api.github.com/users/mkurek/events{/privacy}","received_events_url":"https://api.github.com/users/mkurek/received_events","type":"User","site_admin":false},"body":"add filter to get only costs for accepted dates, ex. \r\n```\r\ndate__in=CostDateStatus.objects.filter(accepted=True, date__gte=start_date, date__lte=end_date).values_list('date', flat=True)\r\n```","created_at":"2015-03-02T07:39:16Z","updated_at":"2015-03-02T07:39:16Z","html_url":"https://github.com/allegro/ralph_pricing/pull/393#discussion_r25581863","pull_request_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393","_links":{"self":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/25581863"},"html":{"href":"https://github.com/allegro/ralph_pricing/pull/393#discussion_r25581863"},"pull_request":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393"}}},"pull_request":{"url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393","id":30159989,"html_url":"https://github.com/allegro/ralph_pricing/pull/393","diff_url":"https://github.com/allegro/ralph_pricing/pull/393.diff","patch_url":"https://github.com/allegro/ralph_pricing/pull/393.patch","issue_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/393","number":393,"state":"open","locked":false,"title":"Ras 306","user":{"login":"zefciu","id":135876,"avatar_url":"https://avatars.githubusercontent.com/u/135876?v=3","gravatar_id":"","url":"https://api.github.com/users/zefciu","html_url":"https://github.com/zefciu","followers_url":"https://api.github.com/users/zefciu/followers","following_url":"https://api.github.com/users/zefciu/following{/other_user}","gists_url":"https://api.github.com/users/zefciu/gists{/gist_id}","starred_url":"https://api.github.com/users/zefciu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zefciu/subscriptions","organizations_url":"https://api.github.com/users/zefciu/orgs","repos_url":"https://api.github.com/users/zefciu/repos","events_url":"https://api.github.com/users/zefciu/events{/privacy}","received_events_url":"https://api.github.com/users/zefciu/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-27T11:42:23Z","updated_at":"2015-03-02T07:39:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":{"url":"https://api.github.com/repos/allegro/ralph_pricing/milestones/1","html_url":"https://github.com/allegro/ralph_pricing/milestones/costs-per-pricing-object","labels_url":"https://api.github.com/repos/allegro/ralph_pricing/milestones/1/labels","id":998748,"number":1,"title":"costs-per-pricing-object","description":null,"creator":{"login":"mkurek","id":107437,"avatar_url":"https://avatars.githubusercontent.com/u/107437?v=3","gravatar_id":"","url":"https://api.github.com/users/mkurek","html_url":"https://github.com/mkurek","followers_url":"https://api.github.com/users/mkurek/followers","following_url":"https://api.github.com/users/mkurek/following{/other_user}","gists_url":"https://api.github.com/users/mkurek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkurek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkurek/subscriptions","organizations_url":"https://api.github.com/users/mkurek/orgs","repos_url":"https://api.github.com/users/mkurek/repos","events_url":"https://api.github.com/users/mkurek/events{/privacy}","received_events_url":"https://api.github.com/users/mkurek/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":2,"state":"open","created_at":"2015-02-27T12:46:54Z","updated_at":"2015-02-27T14:54:40Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393/commits","review_comments_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393/comments","review_comment_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/393/comments","statuses_url":"https://api.github.com/repos/allegro/ralph_pricing/statuses/d2bcaba82e3ed8d715991ecd0e7d0ed91b4bf260","head":{"label":"zefciu:RAS-306","ref":"RAS-306","sha":"d2bcaba82e3ed8d715991ecd0e7d0ed91b4bf260","user":{"login":"zefciu","id":135876,"avatar_url":"https://avatars.githubusercontent.com/u/135876?v=3","gravatar_id":"","url":"https://api.github.com/users/zefciu","html_url":"https://github.com/zefciu","followers_url":"https://api.github.com/users/zefciu/followers","following_url":"https://api.github.com/users/zefciu/following{/other_user}","gists_url":"https://api.github.com/users/zefciu/gists{/gist_id}","starred_url":"https://api.github.com/users/zefciu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zefciu/subscriptions","organizations_url":"https://api.github.com/users/zefciu/orgs","repos_url":"https://api.github.com/users/zefciu/repos","events_url":"https://api.github.com/users/zefciu/events{/privacy}","received_events_url":"https://api.github.com/users/zefciu/received_events","type":"User","site_admin":false},"repo":{"id":13270826,"name":"ralph_pricing","full_name":"zefciu/ralph_pricing","owner":{"login":"zefciu","id":135876,"avatar_url":"https://avatars.githubusercontent.com/u/135876?v=3","gravatar_id":"","url":"https://api.github.com/users/zefciu","html_url":"https://github.com/zefciu","followers_url":"https://api.github.com/users/zefciu/followers","following_url":"https://api.github.com/users/zefciu/following{/other_user}","gists_url":"https://api.github.com/users/zefciu/gists{/gist_id}","starred_url":"https://api.github.com/users/zefciu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zefciu/subscriptions","organizations_url":"https://api.github.com/users/zefciu/orgs","repos_url":"https://api.github.com/users/zefciu/repos","events_url":"https://api.github.com/users/zefciu/events{/privacy}","received_events_url":"https://api.github.com/users/zefciu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zefciu/ralph_pricing","description":"A pricing module for Ralph","fork":true,"url":"https://api.github.com/repos/zefciu/ralph_pricing","forks_url":"https://api.github.com/repos/zefciu/ralph_pricing/forks","keys_url":"https://api.github.com/repos/zefciu/ralph_pricing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zefciu/ralph_pricing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zefciu/ralph_pricing/teams","hooks_url":"https://api.github.com/repos/zefciu/ralph_pricing/hooks","issue_events_url":"https://api.github.com/repos/zefciu/ralph_pricing/issues/events{/number}","events_url":"https://api.github.com/repos/zefciu/ralph_pricing/events","assignees_url":"https://api.github.com/repos/zefciu/ralph_pricing/assignees{/user}","branches_url":"https://api.github.com/repos/zefciu/ralph_pricing/branches{/branch}","tags_url":"https://api.github.com/repos/zefciu/ralph_pricing/tags","blobs_url":"https://api.github.com/repos/zefciu/ralph_pricing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zefciu/ralph_pricing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zefciu/ralph_pricing/git/refs{/sha}","trees_url":"https://api.github.com/repos/zefciu/ralph_pricing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zefciu/ralph_pricing/statuses/{sha}","languages_url":"https://api.github.com/repos/zefciu/ralph_pricing/languages","stargazers_url":"https://api.github.com/repos/zefciu/ralph_pricing/stargazers","contributors_url":"https://api.github.com/repos/zefciu/ralph_pricing/contributors","subscribers_url":"https://api.github.com/repos/zefciu/ralph_pricing/subscribers","subscription_url":"https://api.github.com/repos/zefciu/ralph_pricing/subscription","commits_url":"https://api.github.com/repos/zefciu/ralph_pricing/commits{/sha}","git_commits_url":"https://api.github.com/repos/zefciu/ralph_pricing/git/commits{/sha}","comments_url":"https://api.github.com/repos/zefciu/ralph_pricing/comments{/number}","issue_comment_url":"https://api.github.com/repos/zefciu/ralph_pricing/issues/comments{/number}","contents_url":"https://api.github.com/repos/zefciu/ralph_pricing/contents/{+path}","compare_url":"https://api.github.com/repos/zefciu/ralph_pricing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zefciu/ralph_pricing/merges","archive_url":"https://api.github.com/repos/zefciu/ralph_pricing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zefciu/ralph_pricing/downloads","issues_url":"https://api.github.com/repos/zefciu/ralph_pricing/issues{/number}","pulls_url":"https://api.github.com/repos/zefciu/ralph_pricing/pulls{/number}","milestones_url":"https://api.github.com/repos/zefciu/ralph_pricing/milestones{/number}","notifications_url":"https://api.github.com/repos/zefciu/ralph_pricing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zefciu/ralph_pricing/labels{/name}","releases_url":"https://api.github.com/repos/zefciu/ralph_pricing/releases{/id}","created_at":"2013-10-02T12:45:20Z","updated_at":"2014-01-30T12:16:38Z","pushed_at":"2015-02-27T11:41:24Z","git_url":"git://github.com/zefciu/ralph_pricing.git","ssh_url":"git@github.com:zefciu/ralph_pricing.git","clone_url":"https://github.com/zefciu/ralph_pricing.git","svn_url":"https://github.com/zefciu/ralph_pricing","homepage":null,"size":4939,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"allegro:feature/ras-284","ref":"feature/ras-284","sha":"85e62558fdd141f796283d0322b4d335640b3c94","user":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=3","gravatar_id":"","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"repo":{"id":9495095,"name":"ralph_pricing","full_name":"allegro/ralph_pricing","owner":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=3","gravatar_id":"","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/allegro/ralph_pricing","description":"A pricing module for Ralph","fork":false,"url":"https://api.github.com/repos/allegro/ralph_pricing","forks_url":"https://api.github.com/repos/allegro/ralph_pricing/forks","keys_url":"https://api.github.com/repos/allegro/ralph_pricing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allegro/ralph_pricing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allegro/ralph_pricing/teams","hooks_url":"https://api.github.com/repos/allegro/ralph_pricing/hooks","issue_events_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/events{/number}","events_url":"https://api.github.com/repos/allegro/ralph_pricing/events","assignees_url":"https://api.github.com/repos/allegro/ralph_pricing/assignees{/user}","branches_url":"https://api.github.com/repos/allegro/ralph_pricing/branches{/branch}","tags_url":"https://api.github.com/repos/allegro/ralph_pricing/tags","blobs_url":"https://api.github.com/repos/allegro/ralph_pricing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allegro/ralph_pricing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allegro/ralph_pricing/git/refs{/sha}","trees_url":"https://api.github.com/repos/allegro/ralph_pricing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allegro/ralph_pricing/statuses/{sha}","languages_url":"https://api.github.com/repos/allegro/ralph_pricing/languages","stargazers_url":"https://api.github.com/repos/allegro/ralph_pricing/stargazers","contributors_url":"https://api.github.com/repos/allegro/ralph_pricing/contributors","subscribers_url":"https://api.github.com/repos/allegro/ralph_pricing/subscribers","subscription_url":"https://api.github.com/repos/allegro/ralph_pricing/subscription","commits_url":"https://api.github.com/repos/allegro/ralph_pricing/commits{/sha}","git_commits_url":"https://api.github.com/repos/allegro/ralph_pricing/git/commits{/sha}","comments_url":"https://api.github.com/repos/allegro/ralph_pricing/comments{/number}","issue_comment_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/comments{/number}","contents_url":"https://api.github.com/repos/allegro/ralph_pricing/contents/{+path}","compare_url":"https://api.github.com/repos/allegro/ralph_pricing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allegro/ralph_pricing/merges","archive_url":"https://api.github.com/repos/allegro/ralph_pricing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allegro/ralph_pricing/downloads","issues_url":"https://api.github.com/repos/allegro/ralph_pricing/issues{/number}","pulls_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls{/number}","milestones_url":"https://api.github.com/repos/allegro/ralph_pricing/milestones{/number}","notifications_url":"https://api.github.com/repos/allegro/ralph_pricing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allegro/ralph_pricing/labels{/name}","releases_url":"https://api.github.com/repos/allegro/ralph_pricing/releases{/id}","created_at":"2013-04-17T10:30:06Z","updated_at":"2015-02-27T15:15:48Z","pushed_at":"2015-03-02T07:17:00Z","git_url":"git://github.com/allegro/ralph_pricing.git","ssh_url":"git@github.com:allegro/ralph_pricing.git","clone_url":"https://github.com/allegro/ralph_pricing.git","svn_url":"https://github.com/allegro/ralph_pricing","homepage":null,"size":8722,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":12,"forks":15,"open_issues":12,"watchers":6,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393"},"html":{"href":"https://github.com/allegro/ralph_pricing/pull/393"},"issue":{"href":"https://api.github.com/repos/allegro/ralph_pricing/issues/393"},"comments":{"href":"https://api.github.com/repos/allegro/ralph_pricing/issues/393/comments"},"review_comments":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393/comments"},"review_comment":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/393/commits"},"statuses":{"href":"https://api.github.com/repos/allegro/ralph_pricing/statuses/d2bcaba82e3ed8d715991ecd0e7d0ed91b4bf260"}}}}