{"action":"created","comment":{"url":"https://api.github.com/repos/totem/docker-image-factory/pulls/comments/56784293","id":56784293,"diff_hunk":"@@ -425,3 +441,89 @@ Factory.prototype.createJob =  function createJob(req, res, context, next) {\n   }\n };\n \n+/**\n+ * Returns an array of job objects\n+ * @returns [] of jobs\n+ */\n+Factory.prototype.getJobs = function getJobs() {\n+  var datastore = this.jobs.get();\n+  var keys = Object.keys(datastore);\n+\n+  var jobs = [];\n+  for(var i = 0; i < keys.length; i++) {\n+    if(keys[i]) {\n+      var id = keys[i];\n+      jobs.push(datastore[id]);\n+    }\n+  }\n+\n+  return jobs;\n+};\n+\n+/**\n+ * Checks for duplicate requests and coalesces them if found\n+ * @param res Response object\n+ * @param context Job context holding job parameters (with defaults applied)\n+ * @returns The original job {} if duplicates found, false if not\n+ */\n+Factory.prototype.coalesceRequests = function coalesceRequests(res, context) {\n+  // Check for duplicate context in an array of jobs\n+  function checkIfDuplicate(jobs) {\n+    for (var j = 0; j < jobs.length; j++) {","path":"lib/factory.js","position":90,"original_position":90,"commit_id":"c01d65c697a16171a419bc99b0c788c5e2f7ed71","original_commit_id":"c01d65c697a16171a419bc99b0c788c5e2f7ed71","user":{"login":"sukrit007","id":758708,"avatar_url":"https://avatars.githubusercontent.com/u/758708?v=3","gravatar_id":"","url":"https://api.github.com/users/sukrit007","html_url":"https://github.com/sukrit007","followers_url":"https://api.github.com/users/sukrit007/followers","following_url":"https://api.github.com/users/sukrit007/following{/other_user}","gists_url":"https://api.github.com/users/sukrit007/gists{/gist_id}","starred_url":"https://api.github.com/users/sukrit007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sukrit007/subscriptions","organizations_url":"https://api.github.com/users/sukrit007/orgs","repos_url":"https://api.github.com/users/sukrit007/repos","events_url":"https://api.github.com/users/sukrit007/events{/privacy}","received_events_url":"https://api.github.com/users/sukrit007/received_events","type":"User","site_admin":false},"body":"**Suggestion**: Possibly use _.find  . See https://lodash.com/docs#find","created_at":"2016-03-21T05:49:59Z","updated_at":"2016-03-21T05:49:59Z","html_url":"https://github.com/totem/docker-image-factory/pull/23#discussion_r56784293","pull_request_url":"https://api.github.com/repos/totem/docker-image-factory/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/totem/docker-image-factory/pulls/comments/56784293"},"html":{"href":"https://github.com/totem/docker-image-factory/pull/23#discussion_r56784293"},"pull_request":{"href":"https://api.github.com/repos/totem/docker-image-factory/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/totem/docker-image-factory/pulls/23","id":62321588,"html_url":"https://github.com/totem/docker-image-factory/pull/23","diff_url":"https://github.com/totem/docker-image-factory/pull/23.diff","patch_url":"https://github.com/totem/docker-image-factory/pull/23.patch","issue_url":"https://api.github.com/repos/totem/docker-image-factory/issues/23","number":23,"state":"open","locked":false,"title":"Feature coalescing support","user":{"login":"FunnyGopher","id":3432646,"avatar_url":"https://avatars.githubusercontent.com/u/3432646?v=3","gravatar_id":"","url":"https://api.github.com/users/FunnyGopher","html_url":"https://github.com/FunnyGopher","followers_url":"https://api.github.com/users/FunnyGopher/followers","following_url":"https://api.github.com/users/FunnyGopher/following{/other_user}","gists_url":"https://api.github.com/users/FunnyGopher/gists{/gist_id}","starred_url":"https://api.github.com/users/FunnyGopher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FunnyGopher/subscriptions","organizations_url":"https://api.github.com/users/FunnyGopher/orgs","repos_url":"https://api.github.com/users/FunnyGopher/repos","events_url":"https://api.github.com/users/FunnyGopher/events{/privacy}","received_events_url":"https://api.github.com/users/FunnyGopher/received_events","type":"User","site_admin":false},"body":"Added coalescing support to save resources. Coalescing time window can be configured in the config in the \"coalescingPeriod\" property. Duplicate requests that are fired while a job is building will be thrown away and redirected to the running job. Duplicate requests that are fired during the coalescing period will also be thrown away and redirected to the original job.","created_at":"2016-03-10T00:39:04Z","updated_at":"2016-03-21T05:49:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f502d90590fd385ac018b7a2a2b61d274027ba7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/totem/docker-image-factory/pulls/23/commits","review_comments_url":"https://api.github.com/repos/totem/docker-image-factory/pulls/23/comments","review_comment_url":"https://api.github.com/repos/totem/docker-image-factory/pulls/comments{/number}","comments_url":"https://api.github.com/repos/totem/docker-image-factory/issues/23/comments","statuses_url":"https://api.github.com/repos/totem/docker-image-factory/statuses/c01d65c697a16171a419bc99b0c788c5e2f7ed71","head":{"label":"totem:feature_coalescing-support","ref":"feature_coalescing-support","sha":"c01d65c697a16171a419bc99b0c788c5e2f7ed71","user":{"login":"totem","id":5487064,"avatar_url":"https://avatars.githubusercontent.com/u/5487064?v=3","gravatar_id":"","url":"https://api.github.com/users/totem","html_url":"https://github.com/totem","followers_url":"https://api.github.com/users/totem/followers","following_url":"https://api.github.com/users/totem/following{/other_user}","gists_url":"https://api.github.com/users/totem/gists{/gist_id}","starred_url":"https://api.github.com/users/totem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/totem/subscriptions","organizations_url":"https://api.github.com/users/totem/orgs","repos_url":"https://api.github.com/users/totem/repos","events_url":"https://api.github.com/users/totem/events{/privacy}","received_events_url":"https://api.github.com/users/totem/received_events","type":"Organization","site_admin":false},"repo":{"id":30269977,"name":"docker-image-factory","full_name":"totem/docker-image-factory","owner":{"login":"totem","id":5487064,"avatar_url":"https://avatars.githubusercontent.com/u/5487064?v=3","gravatar_id":"","url":"https://api.github.com/users/totem","html_url":"https://github.com/totem","followers_url":"https://api.github.com/users/totem/followers","following_url":"https://api.github.com/users/totem/following{/other_user}","gists_url":"https://api.github.com/users/totem/gists{/gist_id}","starred_url":"https://api.github.com/users/totem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/totem/subscriptions","organizations_url":"https://api.github.com/users/totem/orgs","repos_url":"https://api.github.com/users/totem/repos","events_url":"https://api.github.com/users/totem/events{/privacy}","received_events_url":"https://api.github.com/users/totem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/totem/docker-image-factory","description":"Docker Image Factory","fork":false,"url":"https://api.github.com/repos/totem/docker-image-factory","forks_url":"https://api.github.com/repos/totem/docker-image-factory/forks","keys_url":"https://api.github.com/repos/totem/docker-image-factory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/totem/docker-image-factory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/totem/docker-image-factory/teams","hooks_url":"https://api.github.com/repos/totem/docker-image-factory/hooks","issue_events_url":"https://api.github.com/repos/totem/docker-image-factory/issues/events{/number}","events_url":"https://api.github.com/repos/totem/docker-image-factory/events","assignees_url":"https://api.github.com/repos/totem/docker-image-factory/assignees{/user}","branches_url":"https://api.github.com/repos/totem/docker-image-factory/branches{/branch}","tags_url":"https://api.github.com/repos/totem/docker-image-factory/tags","blobs_url":"https://api.github.com/repos/totem/docker-image-factory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/totem/docker-image-factory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/totem/docker-image-factory/git/refs{/sha}","trees_url":"https://api.github.com/repos/totem/docker-image-factory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/totem/docker-image-factory/statuses/{sha}","languages_url":"https://api.github.com/repos/totem/docker-image-factory/languages","stargazers_url":"https://api.github.com/repos/totem/docker-image-factory/stargazers","contributors_url":"https://api.github.com/repos/totem/docker-image-factory/contributors","subscribers_url":"https://api.github.com/repos/totem/docker-image-factory/subscribers","subscription_url":"https://api.github.com/repos/totem/docker-image-factory/subscription","commits_url":"https://api.github.com/repos/totem/docker-image-factory/commits{/sha}","git_commits_url":"https://api.github.com/repos/totem/docker-image-factory/git/commits{/sha}","comments_url":"https://api.github.com/repos/totem/docker-image-factory/comments{/number}","issue_comment_url":"https://api.github.com/repos/totem/docker-image-factory/issues/comments{/number}","contents_url":"https://api.github.com/repos/totem/docker-image-factory/contents/{+path}","compare_url":"https://api.github.com/repos/totem/docker-image-factory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/totem/docker-image-factory/merges","archive_url":"https://api.github.com/repos/totem/docker-image-factory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/totem/docker-image-factory/downloads","issues_url":"https://api.github.com/repos/totem/docker-image-factory/issues{/number}","pulls_url":"https://api.github.com/repos/totem/docker-image-factory/pulls{/number}","milestones_url":"https://api.github.com/repos/totem/docker-image-factory/milestones{/number}","notifications_url":"https://api.github.com/repos/totem/docker-image-factory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/totem/docker-image-factory/labels{/name}","releases_url":"https://api.github.com/repos/totem/docker-image-factory/releases{/id}","deployments_url":"https://api.github.com/repos/totem/docker-image-factory/deployments","created_at":"2015-02-03T23:16:25Z","updated_at":"2016-02-10T23:23:31Z","pushed_at":"2016-03-14T18:17:11Z","git_url":"git://github.com/totem/docker-image-factory.git","ssh_url":"git@github.com:totem/docker-image-factory.git","clone_url":"https://github.com/totem/docker-image-factory.git","svn_url":"https://github.com/totem/docker-image-factory","homepage":null,"size":254,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","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":3,"default_branch":"develop"}},"base":{"label":"totem:develop","ref":"develop","sha":"a04151748ea0ff74ce1dfd6419d02c0f926e97aa","user":{"login":"totem","id":5487064,"avatar_url":"https://avatars.githubusercontent.com/u/5487064?v=3","gravatar_id":"","url":"https://api.github.com/users/totem","html_url":"https://github.com/totem","followers_url":"https://api.github.com/users/totem/followers","following_url":"https://api.github.com/users/totem/following{/other_user}","gists_url":"https://api.github.com/users/totem/gists{/gist_id}","starred_url":"https://api.github.com/users/totem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/totem/subscriptions","organizations_url":"https://api.github.com/users/totem/orgs","repos_url":"https://api.github.com/users/totem/repos","events_url":"https://api.github.com/users/totem/events{/privacy}","received_events_url":"https://api.github.com/users/totem/received_events","type":"Organization","site_admin":false},"repo":{"id":30269977,"name":"docker-image-factory","full_name":"totem/docker-image-factory","owner":{"login":"totem","id":5487064,"avatar_url":"https://avatars.githubusercontent.com/u/5487064?v=3","gravatar_id":"","url":"https://api.github.com/users/totem","html_url":"https://github.com/totem","followers_url":"https://api.github.com/users/totem/followers","following_url":"https://api.github.com/users/totem/following{/other_user}","gists_url":"https://api.github.com/users/totem/gists{/gist_id}","starred_url":"https://api.github.com/users/totem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/totem/subscriptions","organizations_url":"https://api.github.com/users/totem/orgs","repos_url":"https://api.github.com/users/totem/repos","events_url":"https://api.github.com/users/totem/events{/privacy}","received_events_url":"https://api.github.com/users/totem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/totem/docker-image-factory","description":"Docker Image Factory","fork":false,"url":"https://api.github.com/repos/totem/docker-image-factory","forks_url":"https://api.github.com/repos/totem/docker-image-factory/forks","keys_url":"https://api.github.com/repos/totem/docker-image-factory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/totem/docker-image-factory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/totem/docker-image-factory/teams","hooks_url":"https://api.github.com/repos/totem/docker-image-factory/hooks","issue_events_url":"https://api.github.com/repos/totem/docker-image-factory/issues/events{/number}","events_url":"https://api.github.com/repos/totem/docker-image-factory/events","assignees_url":"https://api.github.com/repos/totem/docker-image-factory/assignees{/user}","branches_url":"https://api.github.com/repos/totem/docker-image-factory/branches{/branch}","tags_url":"https://api.github.com/repos/totem/docker-image-factory/tags","blobs_url":"https://api.github.com/repos/totem/docker-image-factory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/totem/docker-image-factory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/totem/docker-image-factory/git/refs{/sha}","trees_url":"https://api.github.com/repos/totem/docker-image-factory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/totem/docker-image-factory/statuses/{sha}","languages_url":"https://api.github.com/repos/totem/docker-image-factory/languages","stargazers_url":"https://api.github.com/repos/totem/docker-image-factory/stargazers","contributors_url":"https://api.github.com/repos/totem/docker-image-factory/contributors","subscribers_url":"https://api.github.com/repos/totem/docker-image-factory/subscribers","subscription_url":"https://api.github.com/repos/totem/docker-image-factory/subscription","commits_url":"https://api.github.com/repos/totem/docker-image-factory/commits{/sha}","git_commits_url":"https://api.github.com/repos/totem/docker-image-factory/git/commits{/sha}","comments_url":"https://api.github.com/repos/totem/docker-image-factory/comments{/number}","issue_comment_url":"https://api.github.com/repos/totem/docker-image-factory/issues/comments{/number}","contents_url":"https://api.github.com/repos/totem/docker-image-factory/contents/{+path}","compare_url":"https://api.github.com/repos/totem/docker-image-factory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/totem/docker-image-factory/merges","archive_url":"https://api.github.com/repos/totem/docker-image-factory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/totem/docker-image-factory/downloads","issues_url":"https://api.github.com/repos/totem/docker-image-factory/issues{/number}","pulls_url":"https://api.github.com/repos/totem/docker-image-factory/pulls{/number}","milestones_url":"https://api.github.com/repos/totem/docker-image-factory/milestones{/number}","notifications_url":"https://api.github.com/repos/totem/docker-image-factory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/totem/docker-image-factory/labels{/name}","releases_url":"https://api.github.com/repos/totem/docker-image-factory/releases{/id}","deployments_url":"https://api.github.com/repos/totem/docker-image-factory/deployments","created_at":"2015-02-03T23:16:25Z","updated_at":"2016-02-10T23:23:31Z","pushed_at":"2016-03-14T18:17:11Z","git_url":"git://github.com/totem/docker-image-factory.git","ssh_url":"git@github.com:totem/docker-image-factory.git","clone_url":"https://github.com/totem/docker-image-factory.git","svn_url":"https://github.com/totem/docker-image-factory","homepage":null,"size":254,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","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":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/totem/docker-image-factory/pulls/23"},"html":{"href":"https://github.com/totem/docker-image-factory/pull/23"},"issue":{"href":"https://api.github.com/repos/totem/docker-image-factory/issues/23"},"comments":{"href":"https://api.github.com/repos/totem/docker-image-factory/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/totem/docker-image-factory/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/totem/docker-image-factory/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/totem/docker-image-factory/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/totem/docker-image-factory/statuses/c01d65c697a16171a419bc99b0c788c5e2f7ed71"}}}}