{"action":"created","comment":{"url":"https://api.github.com/repos/GPII/universal/pulls/comments/41771025","id":41771025,"diff_hunk":"@@ -103,6 +110,150 @@\n     };\n \n     /*\n+\t * Returns a string indicating the matchmaker to select from configuration. Depends on the matchmaker payload.\n+     */\n+    gpii.matchMakerFramework.selectMatchMaker = function (that, matchMakerPayload) {\n+        if (that.options.matchMakerDispatcherDisabled) {\n+            return \"flat\"\n+        }\n+\t\tvar result = gpii.matchMakerFramework.GetPreferredMatchMaker(matchMakerPayload);\n+\t\treturn (result) ? result : gpii.matchMakerFramework.GetCapableMatchMaker(matchMakerPayload);\n+    };\n+\n+    /*\n+\t * Returns if a matchmaker payload contains preferences for selecting a matchmaker.\n+\t * Returns NULL if no matchmaker preference was found.\n+     */\n+\tgpii.matchMakerFramework.GetPreferredMatchMaker = function (matchMakerPayload) {\n+\t\t// Rejection tests\n+\t\tif (matchMakerPayload.preferences === undefined || matchMakerPayload.preferences.contexts === undefined || matchMakerPayload.activeContexts === undefined) {\n+\t\t\treturn null;\n+\t\t}\n+\t\t// Search for mm selection preferences\n+\t\tvar contexts = matchMakerPayload.preferences.contexts;\n+\t\tvar activeContexts = matchMakerPayload.activeContexts;\n+\t\tvar foundPriority = -1;\n+\t\tvar foundMatchMaker;\n+\t\tfluid.each(activeContexts, function (activeContext) {\n+\t\t\tif (contexts[activeContext] && contexts[activeContext].preferences) {\n+\t\t\t\tvar prefs = contexts[activeContext].preferences;\n+\t\t\t\tvar curPriority = 0;\n+\t\t\t\tif (contexts[activeContext].priority) {\n+\t\t\t\t\tcurPriority = contexts[activeContext].priority;\n+\t\t\t\t}\n+\t\t\t\tif ((prefs[\"http://registry.gpii.net/common/matchMakerType\"]) && (curPriority > foundPriority)) {\n+\t\t\t\t\tfoundPriority = curPriority;\n+\t\t\t\t\tfoundMatchMaker = prefs[\"http://registry.gpii.net/common/matchMakerType\"];\n+\t\t\t\t}\n+\t\t\t}\n+\t\t});\n+\t\treturn foundMatchMaker;\n+    };\n+\n+    /*\n+\t * Returns the Matchmaker that best matches to the playload based on its capabilities.\n+\t * See MatchMakerCapabilities.json.\n+     */\n+\tgpii.matchMakerFramework.GetCapableMatchMaker = function (matchMakerPayload) {\n+\t\t// Contexts\n+\t\tvar contexts = matchMakerPayload.preferences.contexts;\n+\t\t// Find excluded matchmakers\n+\t\tvar excludedMatchMakers = [];\n+\t\tvar activeContexts = matchMakerPayload.activeContexts;\n+\t\tfluid.each(activeContexts, function (activeContext) {\n+\t\t\tif (contexts[activeContext] && contexts[activeContext].preferences) {\n+\t\t\t\tvar prefs = contexts[activeContext].preferences;\n+\t\t\t\tif (prefs[\"http://registry.gpii.net/common/excludedMatchMakers\"]) {\n+\t\t\t\t\texcludedMatchMakers = prefs[\"http://registry.gpii.net/common/excludedMatchMakers\"];\n+\t\t\t\t}\n+\t\t\t}\n+\t\t});\n+\t\t// Try again block\n+\t\tif ( matchMakerPayload.tryAgain && matchMakerPayload.tryAgain.active) {\n+\t\t\tif (matchMakerPayload.tryAgain[excludedMatchMakers]) {\n+\t\t\t\texcludedMatchMakers.concat(matchMakerPayload.tryAgain.excludedMatchMakers);\n+\t\t\t}\n+\t\t}\n+\t\t// Calculate metric values\n+\t\tvar payloadHasConditions = false;\n+\t\tvar payloadPreferenceCount = 0;\n+\t\tfluid.each(contexts, function (context) {\n+\t\t\tif (context.conditions && (context.conditions.length > 0)) {\n+\t\t\t\tpayloadHasConditions = true;\n+\t\t\t}\n+\t\t\tif (context.preferences) {\n+\t\t\t\tfluid.each(context.preferences, function (pref) {\n+\t\t\t\t\tif (typeof pref == \"object\") {\n+\t\t\t\t\t\tpayloadPreferenceCount += Object.keys(pref).length;\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\t++payloadPreferenceCount;\n+\t\t\t\t\t}\n+\t\t\t\t});\n+\t\t\t}\n+\t\t});\n+\t\t// Compute capabilities\n+\t\tvar foundMatchmaker = false;\n+\t\tvar confidence = {};\n+\t\tfluid.each(gpii.matchMakerFramework.matchmakerCapabilities, function (capability) {\n+\t\t\tif (excludedMatchMakers.indexOf(capability.id) < 0) {","path":"gpii/node_modules/matchMakerFramework/src/MatchMakerFramework.js","position":129,"original_position":129,"commit_id":"3ef0e9a8870b829c0935b46aea8f607d8f498385","original_commit_id":"3ef0e9a8870b829c0935b46aea8f607d8f498385","user":{"login":"kaspermarkus","id":167427,"avatar_url":"https://avatars.githubusercontent.com/u/167427?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspermarkus","html_url":"https://github.com/kaspermarkus","followers_url":"https://api.github.com/users/kaspermarkus/followers","following_url":"https://api.github.com/users/kaspermarkus/following{/other_user}","gists_url":"https://api.github.com/users/kaspermarkus/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspermarkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspermarkus/subscriptions","organizations_url":"https://api.github.com/users/kaspermarkus/orgs","repos_url":"https://api.github.com/users/kaspermarkus/repos","events_url":"https://api.github.com/users/kaspermarkus/events{/privacy}","received_events_url":"https://api.github.com/users/kaspermarkus/received_events","type":"User","site_admin":false},"body":"could you call the `id` in capabilities `matchMakerId` or something like that... Down here the straight `id` reference becomes quite confusing, and one think it refers to the id of the capability","created_at":"2015-10-12T15:53:20Z","updated_at":"2015-10-12T15:53:20Z","html_url":"https://github.com/GPII/universal/pull/404#discussion_r41771025","pull_request_url":"https://api.github.com/repos/GPII/universal/pulls/404","_links":{"self":{"href":"https://api.github.com/repos/GPII/universal/pulls/comments/41771025"},"html":{"href":"https://github.com/GPII/universal/pull/404#discussion_r41771025"},"pull_request":{"href":"https://api.github.com/repos/GPII/universal/pulls/404"}}},"pull_request":{"url":"https://api.github.com/repos/GPII/universal/pulls/404","id":47434514,"html_url":"https://github.com/GPII/universal/pull/404","diff_url":"https://github.com/GPII/universal/pull/404.diff","patch_url":"https://github.com/GPII/universal/pull/404.patch","issue_url":"https://api.github.com/repos/GPII/universal/issues/404","number":404,"state":"open","locked":false,"title":"GPII-1110: Added preference-based dispatching and try different","user":{"login":"kaspermarkus","id":167427,"avatar_url":"https://avatars.githubusercontent.com/u/167427?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspermarkus","html_url":"https://github.com/kaspermarkus","followers_url":"https://api.github.com/users/kaspermarkus/followers","following_url":"https://api.github.com/users/kaspermarkus/following{/other_user}","gists_url":"https://api.github.com/users/kaspermarkus/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspermarkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspermarkus/subscriptions","organizations_url":"https://api.github.com/users/kaspermarkus/orgs","repos_url":"https://api.github.com/users/kaspermarkus/repos","events_url":"https://api.github.com/users/kaspermarkus/events{/privacy}","received_events_url":"https://api.github.com/users/kaspermarkus/received_events","type":"User","site_admin":false},"body":"New version of https://github.com/GPII/universal/pull/287, since that pull request is heavily polluted by updates to master and githubs inability to properly diff","created_at":"2015-10-12T15:44:03Z","updated_at":"2015-10-12T15:53:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c6cf7ec35d2a263118b9122289496f88988ba48","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GPII/universal/pulls/404/commits","review_comments_url":"https://api.github.com/repos/GPII/universal/pulls/404/comments","review_comment_url":"https://api.github.com/repos/GPII/universal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GPII/universal/issues/404/comments","statuses_url":"https://api.github.com/repos/GPII/universal/statuses/3ef0e9a8870b829c0935b46aea8f607d8f498385","head":{"label":"kaspermarkus:andy-branch","ref":"andy-branch","sha":"3ef0e9a8870b829c0935b46aea8f607d8f498385","user":{"login":"kaspermarkus","id":167427,"avatar_url":"https://avatars.githubusercontent.com/u/167427?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspermarkus","html_url":"https://github.com/kaspermarkus","followers_url":"https://api.github.com/users/kaspermarkus/followers","following_url":"https://api.github.com/users/kaspermarkus/following{/other_user}","gists_url":"https://api.github.com/users/kaspermarkus/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspermarkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspermarkus/subscriptions","organizations_url":"https://api.github.com/users/kaspermarkus/orgs","repos_url":"https://api.github.com/users/kaspermarkus/repos","events_url":"https://api.github.com/users/kaspermarkus/events{/privacy}","received_events_url":"https://api.github.com/users/kaspermarkus/received_events","type":"User","site_admin":false},"repo":{"id":3630398,"name":"universal","full_name":"kaspermarkus/universal","owner":{"login":"kaspermarkus","id":167427,"avatar_url":"https://avatars.githubusercontent.com/u/167427?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspermarkus","html_url":"https://github.com/kaspermarkus","followers_url":"https://api.github.com/users/kaspermarkus/followers","following_url":"https://api.github.com/users/kaspermarkus/following{/other_user}","gists_url":"https://api.github.com/users/kaspermarkus/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspermarkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspermarkus/subscriptions","organizations_url":"https://api.github.com/users/kaspermarkus/orgs","repos_url":"https://api.github.com/users/kaspermarkus/repos","events_url":"https://api.github.com/users/kaspermarkus/events{/privacy}","received_events_url":"https://api.github.com/users/kaspermarkus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kaspermarkus/universal","description":"Cross platform, core components of the GPII personalization infrastructure","fork":true,"url":"https://api.github.com/repos/kaspermarkus/universal","forks_url":"https://api.github.com/repos/kaspermarkus/universal/forks","keys_url":"https://api.github.com/repos/kaspermarkus/universal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaspermarkus/universal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaspermarkus/universal/teams","hooks_url":"https://api.github.com/repos/kaspermarkus/universal/hooks","issue_events_url":"https://api.github.com/repos/kaspermarkus/universal/issues/events{/number}","events_url":"https://api.github.com/repos/kaspermarkus/universal/events","assignees_url":"https://api.github.com/repos/kaspermarkus/universal/assignees{/user}","branches_url":"https://api.github.com/repos/kaspermarkus/universal/branches{/branch}","tags_url":"https://api.github.com/repos/kaspermarkus/universal/tags","blobs_url":"https://api.github.com/repos/kaspermarkus/universal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaspermarkus/universal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaspermarkus/universal/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaspermarkus/universal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaspermarkus/universal/statuses/{sha}","languages_url":"https://api.github.com/repos/kaspermarkus/universal/languages","stargazers_url":"https://api.github.com/repos/kaspermarkus/universal/stargazers","contributors_url":"https://api.github.com/repos/kaspermarkus/universal/contributors","subscribers_url":"https://api.github.com/repos/kaspermarkus/universal/subscribers","subscription_url":"https://api.github.com/repos/kaspermarkus/universal/subscription","commits_url":"https://api.github.com/repos/kaspermarkus/universal/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaspermarkus/universal/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaspermarkus/universal/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaspermarkus/universal/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaspermarkus/universal/contents/{+path}","compare_url":"https://api.github.com/repos/kaspermarkus/universal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaspermarkus/universal/merges","archive_url":"https://api.github.com/repos/kaspermarkus/universal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaspermarkus/universal/downloads","issues_url":"https://api.github.com/repos/kaspermarkus/universal/issues{/number}","pulls_url":"https://api.github.com/repos/kaspermarkus/universal/pulls{/number}","milestones_url":"https://api.github.com/repos/kaspermarkus/universal/milestones{/number}","notifications_url":"https://api.github.com/repos/kaspermarkus/universal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaspermarkus/universal/labels{/name}","releases_url":"https://api.github.com/repos/kaspermarkus/universal/releases{/id}","created_at":"2012-03-05T19:15:52Z","updated_at":"2015-04-15T09:45:40Z","pushed_at":"2015-10-12T12:47:40Z","git_url":"git://github.com/kaspermarkus/universal.git","ssh_url":"git@github.com:kaspermarkus/universal.git","clone_url":"https://github.com/kaspermarkus/universal.git","svn_url":"https://github.com/kaspermarkus/universal","homepage":"gpii.net","size":6584,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"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":"GPII:master","ref":"master","sha":"f39361ff9da4f329f0db0dceeba1a794ba1ca0e9","user":{"login":"GPII","id":1343050,"avatar_url":"https://avatars.githubusercontent.com/u/1343050?v=3","gravatar_id":"","url":"https://api.github.com/users/GPII","html_url":"https://github.com/GPII","followers_url":"https://api.github.com/users/GPII/followers","following_url":"https://api.github.com/users/GPII/following{/other_user}","gists_url":"https://api.github.com/users/GPII/gists{/gist_id}","starred_url":"https://api.github.com/users/GPII/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPII/subscriptions","organizations_url":"https://api.github.com/users/GPII/orgs","repos_url":"https://api.github.com/users/GPII/repos","events_url":"https://api.github.com/users/GPII/events{/privacy}","received_events_url":"https://api.github.com/users/GPII/received_events","type":"Organization","site_admin":false},"repo":{"id":3623720,"name":"universal","full_name":"GPII/universal","owner":{"login":"GPII","id":1343050,"avatar_url":"https://avatars.githubusercontent.com/u/1343050?v=3","gravatar_id":"","url":"https://api.github.com/users/GPII","html_url":"https://github.com/GPII","followers_url":"https://api.github.com/users/GPII/followers","following_url":"https://api.github.com/users/GPII/following{/other_user}","gists_url":"https://api.github.com/users/GPII/gists{/gist_id}","starred_url":"https://api.github.com/users/GPII/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPII/subscriptions","organizations_url":"https://api.github.com/users/GPII/orgs","repos_url":"https://api.github.com/users/GPII/repos","events_url":"https://api.github.com/users/GPII/events{/privacy}","received_events_url":"https://api.github.com/users/GPII/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GPII/universal","description":"Cross platform, core components of the GPII personalization infrastructure","fork":false,"url":"https://api.github.com/repos/GPII/universal","forks_url":"https://api.github.com/repos/GPII/universal/forks","keys_url":"https://api.github.com/repos/GPII/universal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GPII/universal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GPII/universal/teams","hooks_url":"https://api.github.com/repos/GPII/universal/hooks","issue_events_url":"https://api.github.com/repos/GPII/universal/issues/events{/number}","events_url":"https://api.github.com/repos/GPII/universal/events","assignees_url":"https://api.github.com/repos/GPII/universal/assignees{/user}","branches_url":"https://api.github.com/repos/GPII/universal/branches{/branch}","tags_url":"https://api.github.com/repos/GPII/universal/tags","blobs_url":"https://api.github.com/repos/GPII/universal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GPII/universal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GPII/universal/git/refs{/sha}","trees_url":"https://api.github.com/repos/GPII/universal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GPII/universal/statuses/{sha}","languages_url":"https://api.github.com/repos/GPII/universal/languages","stargazers_url":"https://api.github.com/repos/GPII/universal/stargazers","contributors_url":"https://api.github.com/repos/GPII/universal/contributors","subscribers_url":"https://api.github.com/repos/GPII/universal/subscribers","subscription_url":"https://api.github.com/repos/GPII/universal/subscription","commits_url":"https://api.github.com/repos/GPII/universal/commits{/sha}","git_commits_url":"https://api.github.com/repos/GPII/universal/git/commits{/sha}","comments_url":"https://api.github.com/repos/GPII/universal/comments{/number}","issue_comment_url":"https://api.github.com/repos/GPII/universal/issues/comments{/number}","contents_url":"https://api.github.com/repos/GPII/universal/contents/{+path}","compare_url":"https://api.github.com/repos/GPII/universal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GPII/universal/merges","archive_url":"https://api.github.com/repos/GPII/universal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GPII/universal/downloads","issues_url":"https://api.github.com/repos/GPII/universal/issues{/number}","pulls_url":"https://api.github.com/repos/GPII/universal/pulls{/number}","milestones_url":"https://api.github.com/repos/GPII/universal/milestones{/number}","notifications_url":"https://api.github.com/repos/GPII/universal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GPII/universal/labels{/name}","releases_url":"https://api.github.com/repos/GPII/universal/releases{/id}","created_at":"2012-03-05T04:01:44Z","updated_at":"2015-06-03T18:28:28Z","pushed_at":"2015-10-12T15:44:04Z","git_url":"git://github.com/GPII/universal.git","ssh_url":"git@github.com:GPII/universal.git","clone_url":"https://github.com/GPII/universal.git","svn_url":"https://github.com/GPII/universal","homepage":"gpii.net","size":95119,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":32,"forks":47,"open_issues":32,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GPII/universal/pulls/404"},"html":{"href":"https://github.com/GPII/universal/pull/404"},"issue":{"href":"https://api.github.com/repos/GPII/universal/issues/404"},"comments":{"href":"https://api.github.com/repos/GPII/universal/issues/404/comments"},"review_comments":{"href":"https://api.github.com/repos/GPII/universal/pulls/404/comments"},"review_comment":{"href":"https://api.github.com/repos/GPII/universal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GPII/universal/pulls/404/commits"},"statuses":{"href":"https://api.github.com/repos/GPII/universal/statuses/3ef0e9a8870b829c0935b46aea8f607d8f498385"}}}}