{"action":"created","comment":{"url":"https://api.github.com/repos/andreskir/listing-tracker/pulls/comments/53165991","id":53165991,"diff_hunk":"@@ -1 +1,66 @@\n-# Place your code here\n\\ No newline at end of file\n+_ = require('lodash')\n+async = require('async')\n+request = require('request')\n+\n+ml_host = 'https://api.mercadolibre.com:443'\n+server = 'http://localhost:9000'\n+seller_id = 154901871\n+req_max = 5\n+page_limit = 50\n+\n+getArticlesBySeller = (seller_id, offset, limit, callback) ->\n+  request\n+    uri: ml_host + \"/sites/MLM/search?seller_id=#{seller_id}&offset=#{offset}&limit=#{page_limit}\"\n+    method: 'GET'\n+    json: true\n+    callback\n+\n+saveArticles = (articles, callback) ->\n+  request\n+    url: server + '/listings/upsert'\n+    method: 'POST'\n+    json: true\n+    body: articles\n+    callback\n+\n+newPage = (page) -> \n+  seller_id: seller_id\n+  offset: page * page_limit\n+  limit: page_limit\n+  page: page\n+\n+savePage = (page, callback) ->\n+  articles = _.map page.results, (result) ->\n+    _.defaults _.pick(result, ['title', 'seller_id', 'sold_quantity']), (listing_id: result.id, seller_id: page.seller.id)\n+  \n+  saveArticles articles, (err, res) ->\n+    callback(err, page)\n+\n+needProcessMorePages = (task, total) ->\n+  task.page == 0 && total > page_limit\n+\n+generateNewPages = (queue, total, callbacks) ->\n+  amountPages = Math.ceil(total / page_limit)\n+  processPage queue, (newPage page), callbacks for page in [1..amountPages - 1]\n+\n+processPage = (queue, task, callbacks) ->\n+  callbacks.start(task)\n+  queue.push task,\n+    (err) ->\n+      result = task.res\n+      generateNewPages queue, result.paging.total, callbacks if needProcessMorePages(task, result.paging.total)\n+      savePage result, callbacks.finish\n+\n+exports.process = (callbacks) ->\n+  \n+  queue = async.queue (task, callback) ->\n+    console.log 'Start process queue\\'s item'\n+    getArticlesBySeller task.seller_id, task.offset, task.limit, (err, res) ->\n+      task.res = res.body if not err\n+      console.log 'Finish process queue\\'s item'\n+      callback(err)\n+    , req_max","path":"jobs/sellerListingsUpdater/src/run.coffee","position":64,"original_position":64,"commit_id":"200411eb0c86aa29143f236c7dd5497286b036d4","original_commit_id":"200411eb0c86aa29143f236c7dd5497286b036d4","user":{"login":"andreskir","id":3473573,"avatar_url":"https://avatars.githubusercontent.com/u/3473573?v=3","gravatar_id":"","url":"https://api.github.com/users/andreskir","html_url":"https://github.com/andreskir","followers_url":"https://api.github.com/users/andreskir/followers","following_url":"https://api.github.com/users/andreskir/following{/other_user}","gists_url":"https://api.github.com/users/andreskir/gists{/gist_id}","starred_url":"https://api.github.com/users/andreskir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreskir/subscriptions","organizations_url":"https://api.github.com/users/andreskir/orgs","repos_url":"https://api.github.com/users/andreskir/repos","events_url":"https://api.github.com/users/andreskir/events{/privacy}","received_events_url":"https://api.github.com/users/andreskir/received_events","type":"User","site_admin":false},"body":"El problema de que no te anda la concurrencia es nada más que un error de tabulación (temas de coffee). Así como está el **req_max** lo estás pasando como tercer parámetro a **getArticlesBySeller** en lugar de ser el segundo parámetro de **async.queue**. Borrarle un TAB lo soluciona.","created_at":"2016-02-17T13:56:46Z","updated_at":"2016-02-17T13:56:46Z","html_url":"https://github.com/andreskir/listing-tracker/pull/1#discussion_r53165991","pull_request_url":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andreskir/listing-tracker/pulls/comments/53165991"},"html":{"href":"https://github.com/andreskir/listing-tracker/pull/1#discussion_r53165991"},"pull_request":{"href":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1","id":59503108,"html_url":"https://github.com/andreskir/listing-tracker/pull/1","diff_url":"https://github.com/andreskir/listing-tracker/pull/1.diff","patch_url":"https://github.com/andreskir/listing-tracker/pull/1.patch","issue_url":"https://api.github.com/repos/andreskir/listing-tracker/issues/1","number":1,"state":"open","locked":false,"title":"Feature/seller listings updater","user":{"login":"gastonprieto","id":770816,"avatar_url":"https://avatars.githubusercontent.com/u/770816?v=3","gravatar_id":"","url":"https://api.github.com/users/gastonprieto","html_url":"https://github.com/gastonprieto","followers_url":"https://api.github.com/users/gastonprieto/followers","following_url":"https://api.github.com/users/gastonprieto/following{/other_user}","gists_url":"https://api.github.com/users/gastonprieto/gists{/gist_id}","starred_url":"https://api.github.com/users/gastonprieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gastonprieto/subscriptions","organizations_url":"https://api.github.com/users/gastonprieto/orgs","repos_url":"https://api.github.com/users/gastonprieto/repos","events_url":"https://api.github.com/users/gastonprieto/events{/privacy}","received_events_url":"https://api.github.com/users/gastonprieto/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-16T15:06:05Z","updated_at":"2016-02-17T13:56:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e685ad533f3790c7853416d5eb314cb02c1445c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andreskir/listing-tracker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andreskir/listing-tracker/issues/1/comments","statuses_url":"https://api.github.com/repos/andreskir/listing-tracker/statuses/200411eb0c86aa29143f236c7dd5497286b036d4","head":{"label":"gastonprieto:feature/seller-listings-updater","ref":"feature/seller-listings-updater","sha":"200411eb0c86aa29143f236c7dd5497286b036d4","user":{"login":"gastonprieto","id":770816,"avatar_url":"https://avatars.githubusercontent.com/u/770816?v=3","gravatar_id":"","url":"https://api.github.com/users/gastonprieto","html_url":"https://github.com/gastonprieto","followers_url":"https://api.github.com/users/gastonprieto/followers","following_url":"https://api.github.com/users/gastonprieto/following{/other_user}","gists_url":"https://api.github.com/users/gastonprieto/gists{/gist_id}","starred_url":"https://api.github.com/users/gastonprieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gastonprieto/subscriptions","organizations_url":"https://api.github.com/users/gastonprieto/orgs","repos_url":"https://api.github.com/users/gastonprieto/repos","events_url":"https://api.github.com/users/gastonprieto/events{/privacy}","received_events_url":"https://api.github.com/users/gastonprieto/received_events","type":"User","site_admin":false},"repo":{"id":51628970,"name":"listing-tracker","full_name":"gastonprieto/listing-tracker","owner":{"login":"gastonprieto","id":770816,"avatar_url":"https://avatars.githubusercontent.com/u/770816?v=3","gravatar_id":"","url":"https://api.github.com/users/gastonprieto","html_url":"https://github.com/gastonprieto","followers_url":"https://api.github.com/users/gastonprieto/followers","following_url":"https://api.github.com/users/gastonprieto/following{/other_user}","gists_url":"https://api.github.com/users/gastonprieto/gists{/gist_id}","starred_url":"https://api.github.com/users/gastonprieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gastonprieto/subscriptions","organizations_url":"https://api.github.com/users/gastonprieto/orgs","repos_url":"https://api.github.com/users/gastonprieto/repos","events_url":"https://api.github.com/users/gastonprieto/events{/privacy}","received_events_url":"https://api.github.com/users/gastonprieto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gastonprieto/listing-tracker","description":"","fork":true,"url":"https://api.github.com/repos/gastonprieto/listing-tracker","forks_url":"https://api.github.com/repos/gastonprieto/listing-tracker/forks","keys_url":"https://api.github.com/repos/gastonprieto/listing-tracker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gastonprieto/listing-tracker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gastonprieto/listing-tracker/teams","hooks_url":"https://api.github.com/repos/gastonprieto/listing-tracker/hooks","issue_events_url":"https://api.github.com/repos/gastonprieto/listing-tracker/issues/events{/number}","events_url":"https://api.github.com/repos/gastonprieto/listing-tracker/events","assignees_url":"https://api.github.com/repos/gastonprieto/listing-tracker/assignees{/user}","branches_url":"https://api.github.com/repos/gastonprieto/listing-tracker/branches{/branch}","tags_url":"https://api.github.com/repos/gastonprieto/listing-tracker/tags","blobs_url":"https://api.github.com/repos/gastonprieto/listing-tracker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gastonprieto/listing-tracker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gastonprieto/listing-tracker/git/refs{/sha}","trees_url":"https://api.github.com/repos/gastonprieto/listing-tracker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gastonprieto/listing-tracker/statuses/{sha}","languages_url":"https://api.github.com/repos/gastonprieto/listing-tracker/languages","stargazers_url":"https://api.github.com/repos/gastonprieto/listing-tracker/stargazers","contributors_url":"https://api.github.com/repos/gastonprieto/listing-tracker/contributors","subscribers_url":"https://api.github.com/repos/gastonprieto/listing-tracker/subscribers","subscription_url":"https://api.github.com/repos/gastonprieto/listing-tracker/subscription","commits_url":"https://api.github.com/repos/gastonprieto/listing-tracker/commits{/sha}","git_commits_url":"https://api.github.com/repos/gastonprieto/listing-tracker/git/commits{/sha}","comments_url":"https://api.github.com/repos/gastonprieto/listing-tracker/comments{/number}","issue_comment_url":"https://api.github.com/repos/gastonprieto/listing-tracker/issues/comments{/number}","contents_url":"https://api.github.com/repos/gastonprieto/listing-tracker/contents/{+path}","compare_url":"https://api.github.com/repos/gastonprieto/listing-tracker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gastonprieto/listing-tracker/merges","archive_url":"https://api.github.com/repos/gastonprieto/listing-tracker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gastonprieto/listing-tracker/downloads","issues_url":"https://api.github.com/repos/gastonprieto/listing-tracker/issues{/number}","pulls_url":"https://api.github.com/repos/gastonprieto/listing-tracker/pulls{/number}","milestones_url":"https://api.github.com/repos/gastonprieto/listing-tracker/milestones{/number}","notifications_url":"https://api.github.com/repos/gastonprieto/listing-tracker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gastonprieto/listing-tracker/labels{/name}","releases_url":"https://api.github.com/repos/gastonprieto/listing-tracker/releases{/id}","deployments_url":"https://api.github.com/repos/gastonprieto/listing-tracker/deployments","created_at":"2016-02-13T02:41:23Z","updated_at":"2016-02-13T02:41:24Z","pushed_at":"2016-02-16T14:33:59Z","git_url":"git://github.com/gastonprieto/listing-tracker.git","ssh_url":"git@github.com:gastonprieto/listing-tracker.git","clone_url":"https://github.com/gastonprieto/listing-tracker.git","svn_url":"https://github.com/gastonprieto/listing-tracker","homepage":null,"size":25,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","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":"andreskir:master","ref":"master","sha":"af53fc9c03311fe424d1a37d14ffaca870f40349","user":{"login":"andreskir","id":3473573,"avatar_url":"https://avatars.githubusercontent.com/u/3473573?v=3","gravatar_id":"","url":"https://api.github.com/users/andreskir","html_url":"https://github.com/andreskir","followers_url":"https://api.github.com/users/andreskir/followers","following_url":"https://api.github.com/users/andreskir/following{/other_user}","gists_url":"https://api.github.com/users/andreskir/gists{/gist_id}","starred_url":"https://api.github.com/users/andreskir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreskir/subscriptions","organizations_url":"https://api.github.com/users/andreskir/orgs","repos_url":"https://api.github.com/users/andreskir/repos","events_url":"https://api.github.com/users/andreskir/events{/privacy}","received_events_url":"https://api.github.com/users/andreskir/received_events","type":"User","site_admin":false},"repo":{"id":51450414,"name":"listing-tracker","full_name":"andreskir/listing-tracker","owner":{"login":"andreskir","id":3473573,"avatar_url":"https://avatars.githubusercontent.com/u/3473573?v=3","gravatar_id":"","url":"https://api.github.com/users/andreskir","html_url":"https://github.com/andreskir","followers_url":"https://api.github.com/users/andreskir/followers","following_url":"https://api.github.com/users/andreskir/following{/other_user}","gists_url":"https://api.github.com/users/andreskir/gists{/gist_id}","starred_url":"https://api.github.com/users/andreskir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreskir/subscriptions","organizations_url":"https://api.github.com/users/andreskir/orgs","repos_url":"https://api.github.com/users/andreskir/repos","events_url":"https://api.github.com/users/andreskir/events{/privacy}","received_events_url":"https://api.github.com/users/andreskir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andreskir/listing-tracker","description":"","fork":false,"url":"https://api.github.com/repos/andreskir/listing-tracker","forks_url":"https://api.github.com/repos/andreskir/listing-tracker/forks","keys_url":"https://api.github.com/repos/andreskir/listing-tracker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andreskir/listing-tracker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andreskir/listing-tracker/teams","hooks_url":"https://api.github.com/repos/andreskir/listing-tracker/hooks","issue_events_url":"https://api.github.com/repos/andreskir/listing-tracker/issues/events{/number}","events_url":"https://api.github.com/repos/andreskir/listing-tracker/events","assignees_url":"https://api.github.com/repos/andreskir/listing-tracker/assignees{/user}","branches_url":"https://api.github.com/repos/andreskir/listing-tracker/branches{/branch}","tags_url":"https://api.github.com/repos/andreskir/listing-tracker/tags","blobs_url":"https://api.github.com/repos/andreskir/listing-tracker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andreskir/listing-tracker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andreskir/listing-tracker/git/refs{/sha}","trees_url":"https://api.github.com/repos/andreskir/listing-tracker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andreskir/listing-tracker/statuses/{sha}","languages_url":"https://api.github.com/repos/andreskir/listing-tracker/languages","stargazers_url":"https://api.github.com/repos/andreskir/listing-tracker/stargazers","contributors_url":"https://api.github.com/repos/andreskir/listing-tracker/contributors","subscribers_url":"https://api.github.com/repos/andreskir/listing-tracker/subscribers","subscription_url":"https://api.github.com/repos/andreskir/listing-tracker/subscription","commits_url":"https://api.github.com/repos/andreskir/listing-tracker/commits{/sha}","git_commits_url":"https://api.github.com/repos/andreskir/listing-tracker/git/commits{/sha}","comments_url":"https://api.github.com/repos/andreskir/listing-tracker/comments{/number}","issue_comment_url":"https://api.github.com/repos/andreskir/listing-tracker/issues/comments{/number}","contents_url":"https://api.github.com/repos/andreskir/listing-tracker/contents/{+path}","compare_url":"https://api.github.com/repos/andreskir/listing-tracker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andreskir/listing-tracker/merges","archive_url":"https://api.github.com/repos/andreskir/listing-tracker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andreskir/listing-tracker/downloads","issues_url":"https://api.github.com/repos/andreskir/listing-tracker/issues{/number}","pulls_url":"https://api.github.com/repos/andreskir/listing-tracker/pulls{/number}","milestones_url":"https://api.github.com/repos/andreskir/listing-tracker/milestones{/number}","notifications_url":"https://api.github.com/repos/andreskir/listing-tracker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andreskir/listing-tracker/labels{/name}","releases_url":"https://api.github.com/repos/andreskir/listing-tracker/releases{/id}","deployments_url":"https://api.github.com/repos/andreskir/listing-tracker/deployments","created_at":"2016-02-10T15:39:09Z","updated_at":"2016-02-10T15:39:21Z","pushed_at":"2016-02-16T15:06:05Z","git_url":"git://github.com/andreskir/listing-tracker.git","ssh_url":"git@github.com:andreskir/listing-tracker.git","clone_url":"https://github.com/andreskir/listing-tracker.git","svn_url":"https://github.com/andreskir/listing-tracker","homepage":null,"size":16,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1"},"html":{"href":"https://github.com/andreskir/listing-tracker/pull/1"},"issue":{"href":"https://api.github.com/repos/andreskir/listing-tracker/issues/1"},"comments":{"href":"https://api.github.com/repos/andreskir/listing-tracker/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andreskir/listing-tracker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andreskir/listing-tracker/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andreskir/listing-tracker/statuses/200411eb0c86aa29143f236c7dd5497286b036d4"}}}}