{"action":"created","comment":{"url":"https://api.github.com/repos/netlify/gocommerce/pulls/comments/73921406","id":73921406,"diff_hunk":"@@ -162,17 +186,45 @@ func (a *API) setUserIDFromToken(tx *gorm.DB, user *models.User, order *models.O\n \treturn nil\n }\n \n-func (a *API) createLineItems(tx *gorm.DB, order *models.Order, items []models.LineItem) *HTTPError {\n+func (a *API) createLineItems(ctx context.Context, tx *gorm.DB, order *models.Order, items []*OrderLineItem) *HTTPError {\n+\tsem := make(chan int, MaxConcurrentLookups)\n+\tvar wg sync.WaitGroup\n+\tsharedErr := verificationError{}\n \tfor _, item := range items {\n-\t\titem.ID = 0 // Making sure you can't set this via params\n-\t\titem.OrderID = order.ID\n+\t\tlineItem := &models.LineItem{SKU: item.SKU, Quantity: item.Quantity, Path: item.Path, OrderID: order.ID}\n+\t\torder.LineItems = append(order.LineItems, lineItem)\n+\t\tsem <- 1\n+\t\twg.Add(1)\n+\t\tgo func(item *models.LineItem) {\n+\t\t\t// Stop doing any work if there's already an error\n+\t\t\tif sharedErr.err != nil {\n+\t\t\t\t<-sem\n+\t\t\t\twg.Done()","path":"api/order.go","position":110,"original_position":110,"commit_id":"b2db4b975c6dc3f70801e2275026bce273dbf3f9","original_commit_id":"b2db4b975c6dc3f70801e2275026bce273dbf3f9","user":{"login":"rybit","id":406376,"avatar_url":"https://avatars.githubusercontent.com/u/406376?v=3","gravatar_id":"","url":"https://api.github.com/users/rybit","html_url":"https://github.com/rybit","followers_url":"https://api.github.com/users/rybit/followers","following_url":"https://api.github.com/users/rybit/following{/other_user}","gists_url":"https://api.github.com/users/rybit/gists{/gist_id}","starred_url":"https://api.github.com/users/rybit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rybit/subscriptions","organizations_url":"https://api.github.com/users/rybit/orgs","repos_url":"https://api.github.com/users/rybit/repos","events_url":"https://api.github.com/users/rybit/events{/privacy}","received_events_url":"https://api.github.com/users/rybit/received_events","type":"User","site_admin":false},"body":"optional - put the `wg.Done()` in a defer","created_at":"2016-08-08T17:53:20Z","updated_at":"2016-08-08T17:53:20Z","html_url":"https://github.com/netlify/gocommerce/pull/3#discussion_r73921406","pull_request_url":"https://api.github.com/repos/netlify/gocommerce/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/netlify/gocommerce/pulls/comments/73921406"},"html":{"href":"https://github.com/netlify/gocommerce/pull/3#discussion_r73921406"},"pull_request":{"href":"https://api.github.com/repos/netlify/gocommerce/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/netlify/gocommerce/pulls/3","id":80402450,"html_url":"https://github.com/netlify/gocommerce/pull/3","diff_url":"https://github.com/netlify/gocommerce/pull/3.diff","patch_url":"https://github.com/netlify/gocommerce/pull/3.patch","issue_url":"https://api.github.com/repos/netlify/gocommerce/issues/3","number":3,"state":"closed","locked":false,"title":"Add support for VAT calculations and site settings","user":{"login":"biilmann","id":6515,"avatar_url":"https://avatars.githubusercontent.com/u/6515?v=3","gravatar_id":"","url":"https://api.github.com/users/biilmann","html_url":"https://github.com/biilmann","followers_url":"https://api.github.com/users/biilmann/followers","following_url":"https://api.github.com/users/biilmann/following{/other_user}","gists_url":"https://api.github.com/users/biilmann/gists{/gist_id}","starred_url":"https://api.github.com/users/biilmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biilmann/subscriptions","organizations_url":"https://api.github.com/users/biilmann/orgs","repos_url":"https://api.github.com/users/biilmann/repos","events_url":"https://api.github.com/users/biilmann/events{/privacy}","received_events_url":"https://api.github.com/users/biilmann/received_events","type":"User","site_admin":false},"body":"This includes some API changes. Mainly the line items only\nrequire a Path and a Quantity and are verified when added.\n\nGocommerce will now check the site for a /gocommerce/settings.json\nfile that can currently set VAT rules based on countries/product types.\n\nAn amount must be included when triggering a payment, to verify that\nthe tax calculations the user has been shown in the UI matches what we\nare actually going to charge.","created_at":"2016-08-08T06:58:52Z","updated_at":"2016-08-08T17:53:20Z","closed_at":"2016-08-08T07:06:24Z","merged_at":"2016-08-08T07:06:24Z","merge_commit_sha":"719a2ee3986b7ef8cb8c25e0711983ad1b371353","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/netlify/gocommerce/pulls/3/commits","review_comments_url":"https://api.github.com/repos/netlify/gocommerce/pulls/3/comments","review_comment_url":"https://api.github.com/repos/netlify/gocommerce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netlify/gocommerce/issues/3/comments","statuses_url":"https://api.github.com/repos/netlify/gocommerce/statuses/b2db4b975c6dc3f70801e2275026bce273dbf3f9","head":{"label":"netlify:vat","ref":"vat","sha":"b2db4b975c6dc3f70801e2275026bce273dbf3f9","user":{"login":"netlify","id":7892489,"avatar_url":"https://avatars.githubusercontent.com/u/7892489?v=3","gravatar_id":"","url":"https://api.github.com/users/netlify","html_url":"https://github.com/netlify","followers_url":"https://api.github.com/users/netlify/followers","following_url":"https://api.github.com/users/netlify/following{/other_user}","gists_url":"https://api.github.com/users/netlify/gists{/gist_id}","starred_url":"https://api.github.com/users/netlify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netlify/subscriptions","organizations_url":"https://api.github.com/users/netlify/orgs","repos_url":"https://api.github.com/users/netlify/repos","events_url":"https://api.github.com/users/netlify/events{/privacy}","received_events_url":"https://api.github.com/users/netlify/received_events","type":"Organization","site_admin":false},"repo":{"id":62554992,"name":"gocommerce","full_name":"netlify/gocommerce","owner":{"login":"netlify","id":7892489,"avatar_url":"https://avatars.githubusercontent.com/u/7892489?v=3","gravatar_id":"","url":"https://api.github.com/users/netlify","html_url":"https://github.com/netlify","followers_url":"https://api.github.com/users/netlify/followers","following_url":"https://api.github.com/users/netlify/following{/other_user}","gists_url":"https://api.github.com/users/netlify/gists{/gist_id}","starred_url":"https://api.github.com/users/netlify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netlify/subscriptions","organizations_url":"https://api.github.com/users/netlify/orgs","repos_url":"https://api.github.com/users/netlify/repos","events_url":"https://api.github.com/users/netlify/events{/privacy}","received_events_url":"https://api.github.com/users/netlify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netlify/gocommerce","description":null,"fork":false,"url":"https://api.github.com/repos/netlify/gocommerce","forks_url":"https://api.github.com/repos/netlify/gocommerce/forks","keys_url":"https://api.github.com/repos/netlify/gocommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netlify/gocommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netlify/gocommerce/teams","hooks_url":"https://api.github.com/repos/netlify/gocommerce/hooks","issue_events_url":"https://api.github.com/repos/netlify/gocommerce/issues/events{/number}","events_url":"https://api.github.com/repos/netlify/gocommerce/events","assignees_url":"https://api.github.com/repos/netlify/gocommerce/assignees{/user}","branches_url":"https://api.github.com/repos/netlify/gocommerce/branches{/branch}","tags_url":"https://api.github.com/repos/netlify/gocommerce/tags","blobs_url":"https://api.github.com/repos/netlify/gocommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netlify/gocommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netlify/gocommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/netlify/gocommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netlify/gocommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/netlify/gocommerce/languages","stargazers_url":"https://api.github.com/repos/netlify/gocommerce/stargazers","contributors_url":"https://api.github.com/repos/netlify/gocommerce/contributors","subscribers_url":"https://api.github.com/repos/netlify/gocommerce/subscribers","subscription_url":"https://api.github.com/repos/netlify/gocommerce/subscription","commits_url":"https://api.github.com/repos/netlify/gocommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/netlify/gocommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/netlify/gocommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/netlify/gocommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/netlify/gocommerce/contents/{+path}","compare_url":"https://api.github.com/repos/netlify/gocommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netlify/gocommerce/merges","archive_url":"https://api.github.com/repos/netlify/gocommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netlify/gocommerce/downloads","issues_url":"https://api.github.com/repos/netlify/gocommerce/issues{/number}","pulls_url":"https://api.github.com/repos/netlify/gocommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/netlify/gocommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/netlify/gocommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netlify/gocommerce/labels{/name}","releases_url":"https://api.github.com/repos/netlify/gocommerce/releases{/id}","deployments_url":"https://api.github.com/repos/netlify/gocommerce/deployments","created_at":"2016-07-04T10:48:35Z","updated_at":"2016-07-04T19:12:08Z","pushed_at":"2016-08-08T07:06:24Z","git_url":"git://github.com/netlify/gocommerce.git","ssh_url":"git@github.com:netlify/gocommerce.git","clone_url":"https://github.com/netlify/gocommerce.git","svn_url":"https://github.com/netlify/gocommerce","homepage":null,"size":31,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"netlify:master","ref":"master","sha":"19de9caba5f164807b8d56e9f3a0965b7c12090b","user":{"login":"netlify","id":7892489,"avatar_url":"https://avatars.githubusercontent.com/u/7892489?v=3","gravatar_id":"","url":"https://api.github.com/users/netlify","html_url":"https://github.com/netlify","followers_url":"https://api.github.com/users/netlify/followers","following_url":"https://api.github.com/users/netlify/following{/other_user}","gists_url":"https://api.github.com/users/netlify/gists{/gist_id}","starred_url":"https://api.github.com/users/netlify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netlify/subscriptions","organizations_url":"https://api.github.com/users/netlify/orgs","repos_url":"https://api.github.com/users/netlify/repos","events_url":"https://api.github.com/users/netlify/events{/privacy}","received_events_url":"https://api.github.com/users/netlify/received_events","type":"Organization","site_admin":false},"repo":{"id":62554992,"name":"gocommerce","full_name":"netlify/gocommerce","owner":{"login":"netlify","id":7892489,"avatar_url":"https://avatars.githubusercontent.com/u/7892489?v=3","gravatar_id":"","url":"https://api.github.com/users/netlify","html_url":"https://github.com/netlify","followers_url":"https://api.github.com/users/netlify/followers","following_url":"https://api.github.com/users/netlify/following{/other_user}","gists_url":"https://api.github.com/users/netlify/gists{/gist_id}","starred_url":"https://api.github.com/users/netlify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netlify/subscriptions","organizations_url":"https://api.github.com/users/netlify/orgs","repos_url":"https://api.github.com/users/netlify/repos","events_url":"https://api.github.com/users/netlify/events{/privacy}","received_events_url":"https://api.github.com/users/netlify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netlify/gocommerce","description":null,"fork":false,"url":"https://api.github.com/repos/netlify/gocommerce","forks_url":"https://api.github.com/repos/netlify/gocommerce/forks","keys_url":"https://api.github.com/repos/netlify/gocommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netlify/gocommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netlify/gocommerce/teams","hooks_url":"https://api.github.com/repos/netlify/gocommerce/hooks","issue_events_url":"https://api.github.com/repos/netlify/gocommerce/issues/events{/number}","events_url":"https://api.github.com/repos/netlify/gocommerce/events","assignees_url":"https://api.github.com/repos/netlify/gocommerce/assignees{/user}","branches_url":"https://api.github.com/repos/netlify/gocommerce/branches{/branch}","tags_url":"https://api.github.com/repos/netlify/gocommerce/tags","blobs_url":"https://api.github.com/repos/netlify/gocommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netlify/gocommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netlify/gocommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/netlify/gocommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netlify/gocommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/netlify/gocommerce/languages","stargazers_url":"https://api.github.com/repos/netlify/gocommerce/stargazers","contributors_url":"https://api.github.com/repos/netlify/gocommerce/contributors","subscribers_url":"https://api.github.com/repos/netlify/gocommerce/subscribers","subscription_url":"https://api.github.com/repos/netlify/gocommerce/subscription","commits_url":"https://api.github.com/repos/netlify/gocommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/netlify/gocommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/netlify/gocommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/netlify/gocommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/netlify/gocommerce/contents/{+path}","compare_url":"https://api.github.com/repos/netlify/gocommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netlify/gocommerce/merges","archive_url":"https://api.github.com/repos/netlify/gocommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netlify/gocommerce/downloads","issues_url":"https://api.github.com/repos/netlify/gocommerce/issues{/number}","pulls_url":"https://api.github.com/repos/netlify/gocommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/netlify/gocommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/netlify/gocommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netlify/gocommerce/labels{/name}","releases_url":"https://api.github.com/repos/netlify/gocommerce/releases{/id}","deployments_url":"https://api.github.com/repos/netlify/gocommerce/deployments","created_at":"2016-07-04T10:48:35Z","updated_at":"2016-07-04T19:12:08Z","pushed_at":"2016-08-08T07:06:24Z","git_url":"git://github.com/netlify/gocommerce.git","ssh_url":"git@github.com:netlify/gocommerce.git","clone_url":"https://github.com/netlify/gocommerce.git","svn_url":"https://github.com/netlify/gocommerce","homepage":null,"size":31,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netlify/gocommerce/pulls/3"},"html":{"href":"https://github.com/netlify/gocommerce/pull/3"},"issue":{"href":"https://api.github.com/repos/netlify/gocommerce/issues/3"},"comments":{"href":"https://api.github.com/repos/netlify/gocommerce/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/netlify/gocommerce/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/netlify/gocommerce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netlify/gocommerce/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/netlify/gocommerce/statuses/b2db4b975c6dc3f70801e2275026bce273dbf3f9"}}}}
{"actor":{"display_login":"rybit"}}