{"action":"created","comment":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/comments/42700912","id":42700912,"diff_hunk":"@@ -40,6 +40,7 @@ class Promotion < Spree::Base\n         where(table[:expires_at].eq(nil).or(table[:expires_at].gt(time)))\n     end\n     scope :applied, -> { joins(:order_promotions).uniq }\n+    scope :applied_automatically, -> { where(apply_automatically: true) }","path":"core/app/models/spree/promotion.rb","position":4,"original_position":4,"commit_id":"31d1d3493afb44807c86fd5fe66cfc4bf7e9cb98","original_commit_id":"31d1d3493afb44807c86fd5fe66cfc4bf7e9cb98","user":{"login":"jordan-brough","id":23050,"avatar_url":"https://avatars.githubusercontent.com/u/23050?v=3","gravatar_id":"","url":"https://api.github.com/users/jordan-brough","html_url":"https://github.com/jordan-brough","followers_url":"https://api.github.com/users/jordan-brough/followers","following_url":"https://api.github.com/users/jordan-brough/following{/other_user}","gists_url":"https://api.github.com/users/jordan-brough/gists{/gist_id}","starred_url":"https://api.github.com/users/jordan-brough/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordan-brough/subscriptions","organizations_url":"https://api.github.com/users/jordan-brough/orgs","repos_url":"https://api.github.com/users/jordan-brough/repos","events_url":"https://api.github.com/users/jordan-brough/events{/privacy}","received_events_url":"https://api.github.com/users/jordan-brough/received_events","type":"User","site_admin":false},"body":"I do see that `applied_automatically` matches the naming pattern for `advertised`, it just feels a bit confusing given the `applied` scope.","created_at":"2015-10-22T00:44:09Z","updated_at":"2015-10-22T00:44:09Z","html_url":"https://github.com/solidusio/solidus/pull/458#discussion_r42700912","pull_request_url":"https://api.github.com/repos/solidusio/solidus/pulls/458","_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments/42700912"},"html":{"href":"https://github.com/solidusio/solidus/pull/458#discussion_r42700912"},"pull_request":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/458"}}},"pull_request":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/458","id":48348153,"html_url":"https://github.com/solidusio/solidus/pull/458","diff_url":"https://github.com/solidusio/solidus/pull/458.diff","patch_url":"https://github.com/solidusio/solidus/pull/458.patch","issue_url":"https://api.github.com/repos/solidusio/solidus/issues/458","number":458,"state":"open","locked":false,"title":"Promotion.sale","user":{"login":"metade","id":3056,"avatar_url":"https://avatars.githubusercontent.com/u/3056?v=3","gravatar_id":"","url":"https://api.github.com/users/metade","html_url":"https://github.com/metade","followers_url":"https://api.github.com/users/metade/followers","following_url":"https://api.github.com/users/metade/following{/other_user}","gists_url":"https://api.github.com/users/metade/gists{/gist_id}","starred_url":"https://api.github.com/users/metade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metade/subscriptions","organizations_url":"https://api.github.com/users/metade/orgs","repos_url":"https://api.github.com/users/metade/repos","events_url":"https://api.github.com/users/metade/events{/privacy}","received_events_url":"https://api.github.com/users/metade/received_events","type":"User","site_admin":false},"body":"A promotion with no code or path is currently treated as a sale promotion in Solidus - so it's applied to all orders automatically.\r\n\r\nAs indicated in #419, there are a number of issues with this:\r\n* querying for sale promotions is a performance bottleneck in stores with many promotions/promotion codes\r\n* it's possible to accidentally create a sale promotion by omitting the code/path\r\n\r\nThis PR overcomes these issues by:\r\n* adding a `Spree::Promotion#sale` attribute to specify that a promotion should be handled as a sale promotion\r\n* adding a `Spree::Promotion.sale` scope that is used by `Spree::PromotionHandler::Cart` for finding the active sale promotions\r\n* making the `Spree::Promotion#sale` attribute editable in the admin interface.","created_at":"2015-10-21T15:35:21Z","updated_at":"2015-10-22T00:44:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ed085ec6e3da4d6f938df6d97c2381fc430d3f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/solidusio/solidus/pulls/458/commits","review_comments_url":"https://api.github.com/repos/solidusio/solidus/pulls/458/comments","review_comment_url":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solidusio/solidus/issues/458/comments","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/31d1d3493afb44807c86fd5fe66cfc4bf7e9cb98","head":{"label":"Lostmyname:sale-promotions","ref":"sale-promotions","sha":"31d1d3493afb44807c86fd5fe66cfc4bf7e9cb98","user":{"login":"Lostmyname","id":3286865,"avatar_url":"https://avatars.githubusercontent.com/u/3286865?v=3","gravatar_id":"","url":"https://api.github.com/users/Lostmyname","html_url":"https://github.com/Lostmyname","followers_url":"https://api.github.com/users/Lostmyname/followers","following_url":"https://api.github.com/users/Lostmyname/following{/other_user}","gists_url":"https://api.github.com/users/Lostmyname/gists{/gist_id}","starred_url":"https://api.github.com/users/Lostmyname/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lostmyname/subscriptions","organizations_url":"https://api.github.com/users/Lostmyname/orgs","repos_url":"https://api.github.com/users/Lostmyname/repos","events_url":"https://api.github.com/users/Lostmyname/events{/privacy}","received_events_url":"https://api.github.com/users/Lostmyname/received_events","type":"Organization","site_admin":false},"repo":{"id":42684611,"name":"solidus","full_name":"Lostmyname/solidus","owner":{"login":"Lostmyname","id":3286865,"avatar_url":"https://avatars.githubusercontent.com/u/3286865?v=3","gravatar_id":"","url":"https://api.github.com/users/Lostmyname","html_url":"https://github.com/Lostmyname","followers_url":"https://api.github.com/users/Lostmyname/followers","following_url":"https://api.github.com/users/Lostmyname/following{/other_user}","gists_url":"https://api.github.com/users/Lostmyname/gists{/gist_id}","starred_url":"https://api.github.com/users/Lostmyname/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lostmyname/subscriptions","organizations_url":"https://api.github.com/users/Lostmyname/orgs","repos_url":"https://api.github.com/users/Lostmyname/repos","events_url":"https://api.github.com/users/Lostmyname/events{/privacy}","received_events_url":"https://api.github.com/users/Lostmyname/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Lostmyname/solidus","description":"Solidus, Rails eCommerce System","fork":true,"url":"https://api.github.com/repos/Lostmyname/solidus","forks_url":"https://api.github.com/repos/Lostmyname/solidus/forks","keys_url":"https://api.github.com/repos/Lostmyname/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lostmyname/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lostmyname/solidus/teams","hooks_url":"https://api.github.com/repos/Lostmyname/solidus/hooks","issue_events_url":"https://api.github.com/repos/Lostmyname/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/Lostmyname/solidus/events","assignees_url":"https://api.github.com/repos/Lostmyname/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/Lostmyname/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/Lostmyname/solidus/tags","blobs_url":"https://api.github.com/repos/Lostmyname/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lostmyname/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lostmyname/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lostmyname/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lostmyname/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/Lostmyname/solidus/languages","stargazers_url":"https://api.github.com/repos/Lostmyname/solidus/stargazers","contributors_url":"https://api.github.com/repos/Lostmyname/solidus/contributors","subscribers_url":"https://api.github.com/repos/Lostmyname/solidus/subscribers","subscription_url":"https://api.github.com/repos/Lostmyname/solidus/subscription","commits_url":"https://api.github.com/repos/Lostmyname/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lostmyname/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lostmyname/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lostmyname/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lostmyname/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/Lostmyname/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lostmyname/solidus/merges","archive_url":"https://api.github.com/repos/Lostmyname/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lostmyname/solidus/downloads","issues_url":"https://api.github.com/repos/Lostmyname/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/Lostmyname/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/Lostmyname/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/Lostmyname/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lostmyname/solidus/labels{/name}","releases_url":"https://api.github.com/repos/Lostmyname/solidus/releases{/id}","created_at":"2015-09-17T22:09:31Z","updated_at":"2015-09-17T22:09:34Z","pushed_at":"2015-10-21T22:16:09Z","git_url":"git://github.com/Lostmyname/solidus.git","ssh_url":"git@github.com:Lostmyname/solidus.git","clone_url":"https://github.com/Lostmyname/solidus.git","svn_url":"https://github.com/Lostmyname/solidus","homepage":"http://solidus.io/","size":60240,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"solidusio:master","ref":"master","sha":"800e3fd2572586d0bae52a5a2c19f067dafbee7a","user":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"repo":{"id":30985840,"name":"solidus","full_name":"solidusio/solidus","owner":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solidusio/solidus","description":"Solidus, Rails eCommerce System","fork":false,"url":"https://api.github.com/repos/solidusio/solidus","forks_url":"https://api.github.com/repos/solidusio/solidus/forks","keys_url":"https://api.github.com/repos/solidusio/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solidusio/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solidusio/solidus/teams","hooks_url":"https://api.github.com/repos/solidusio/solidus/hooks","issue_events_url":"https://api.github.com/repos/solidusio/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/solidusio/solidus/events","assignees_url":"https://api.github.com/repos/solidusio/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/solidusio/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/solidusio/solidus/tags","blobs_url":"https://api.github.com/repos/solidusio/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solidusio/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solidusio/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/solidusio/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/solidusio/solidus/languages","stargazers_url":"https://api.github.com/repos/solidusio/solidus/stargazers","contributors_url":"https://api.github.com/repos/solidusio/solidus/contributors","subscribers_url":"https://api.github.com/repos/solidusio/solidus/subscribers","subscription_url":"https://api.github.com/repos/solidusio/solidus/subscription","commits_url":"https://api.github.com/repos/solidusio/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/solidusio/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/solidusio/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/solidusio/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/solidusio/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/solidusio/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solidusio/solidus/merges","archive_url":"https://api.github.com/repos/solidusio/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solidusio/solidus/downloads","issues_url":"https://api.github.com/repos/solidusio/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/solidusio/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/solidusio/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/solidusio/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solidusio/solidus/labels{/name}","releases_url":"https://api.github.com/repos/solidusio/solidus/releases{/id}","created_at":"2015-02-18T20:41:58Z","updated_at":"2015-10-21T23:31:46Z","pushed_at":"2015-10-21T22:16:10Z","git_url":"git://github.com/solidusio/solidus.git","ssh_url":"git@github.com:solidusio/solidus.git","clone_url":"https://github.com/solidusio/solidus.git","svn_url":"https://github.com/solidusio/solidus","homepage":"http://solidus.io/","size":68677,"stargazers_count":69,"watchers_count":69,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":61,"forks":39,"open_issues":61,"watchers":69,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/458"},"html":{"href":"https://github.com/solidusio/solidus/pull/458"},"issue":{"href":"https://api.github.com/repos/solidusio/solidus/issues/458"},"comments":{"href":"https://api.github.com/repos/solidusio/solidus/issues/458/comments"},"review_comments":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/458/comments"},"review_comment":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/458/commits"},"statuses":{"href":"https://api.github.com/repos/solidusio/solidus/statuses/31d1d3493afb44807c86fd5fe66cfc4bf7e9cb98"}}}}