{"action":"created","comment":{"url":"https://api.github.com/repos/aces/Loris/pulls/comments/173918113","pull_request_review_id":103186401,"id":173918113,"diff_hunk":"@@ -0,0 +1,73 @@\n+<?php\n+/**\n+ * This script is the first step to normalizing the  table for projects which store\n+ * comma-separated values. This script splits up cells containing commas by creating new rows for\n+ * each value and maintaining unique combinations of values.\n+ *\n+ * PHP Version 7\n+ *\n+ * @category Main\n+ * @package  Loris\n+ * @author   Liza Levitis <llevitis.mcin@gmail.com>\n+ * @license  Loris license\n+ * @link     https://www.github.com/aces/Loris\n+ */\n+\n+require_once 'generic_includes.php';\n+require_once 'Database.class.inc';\n+require_once 'Utility.class.inc';\n+\n+$DB = \\Database::singleton();\n+\n+/*\n+ * Converts an array of arrays of values for different fields into\n+ * an array of unique combinations of the different values.\n+ */\n+function cartesian($input) {\n+    // filter out empty values\n+    $result = array(array());\n+    foreach ($input as $key => $values) {\n+        $append = array();\n+        foreach($result as $product) {\n+            foreach($values as $item) {\n+                $product[$key] = $item;\n+                // remove $key with empty value so that\n+                // an empty string isn't inserted into the database instead of a default NULL value\n+                if ($product[$key] == \"\") {\n+                    unset($product[$key]);\n+                }\n+                $append[] = $product;\n+            }\n+        }\n+        $result = $append;\n+    }\n+    return $result;\n+}\n+\n+// Get the list of unique IDs from the mri_protocol_3_3 table\n+$mp_idx = $DB->pselect(\"SELECT ID FROM mri_protocol_3\", array());","path":"tools/normalize_protocol_split_rows.php","position":48,"original_position":48,"commit_id":"6d66dc2dcb65bdb62eb45c432af4943c40e3adde","original_commit_id":"6d66dc2dcb65bdb62eb45c432af4943c40e3adde","user":{"login":"MounaSafiHarab","id":15198379,"avatar_url":"https://avatars1.githubusercontent.com/u/15198379?v=4","gravatar_id":"","url":"https://api.github.com/users/MounaSafiHarab","html_url":"https://github.com/MounaSafiHarab","followers_url":"https://api.github.com/users/MounaSafiHarab/followers","following_url":"https://api.github.com/users/MounaSafiHarab/following{/other_user}","gists_url":"https://api.github.com/users/MounaSafiHarab/gists{/gist_id}","starred_url":"https://api.github.com/users/MounaSafiHarab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MounaSafiHarab/subscriptions","organizations_url":"https://api.github.com/users/MounaSafiHarab/orgs","repos_url":"https://api.github.com/users/MounaSafiHarab/repos","events_url":"https://api.github.com/users/MounaSafiHarab/events{/privacy}","received_events_url":"https://api.github.com/users/MounaSafiHarab/received_events","type":"User","site_admin":false},"body":"I don't think we have a table called mri_protocol_3 :)","created_at":"2018-03-12T19:24:31Z","updated_at":"2018-03-12T19:24:31Z","html_url":"https://github.com/aces/Loris/pull/3523#discussion_r173918113","pull_request_url":"https://api.github.com/repos/aces/Loris/pulls/3523","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/aces/Loris/pulls/comments/173918113"},"html":{"href":"https://github.com/aces/Loris/pull/3523#discussion_r173918113"},"pull_request":{"href":"https://api.github.com/repos/aces/Loris/pulls/3523"}}},"pull_request":{"url":"https://api.github.com/repos/aces/Loris/pulls/3523","id":172096758,"html_url":"https://github.com/aces/Loris/pull/3523","diff_url":"https://github.com/aces/Loris/pull/3523.diff","patch_url":"https://github.com/aces/Loris/pull/3523.patch","issue_url":"https://api.github.com/repos/aces/Loris/issues/3523","number":3523,"state":"open","locked":false,"title":"[Tools] Normalizing mri_protocol: split up comma-separated values ","user":{"login":"llevitis","id":17363738,"avatar_url":"https://avatars3.githubusercontent.com/u/17363738?v=4","gravatar_id":"","url":"https://api.github.com/users/llevitis","html_url":"https://github.com/llevitis","followers_url":"https://api.github.com/users/llevitis/followers","following_url":"https://api.github.com/users/llevitis/following{/other_user}","gists_url":"https://api.github.com/users/llevitis/gists{/gist_id}","starred_url":"https://api.github.com/users/llevitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llevitis/subscriptions","organizations_url":"https://api.github.com/users/llevitis/orgs","repos_url":"https://api.github.com/users/llevitis/repos","events_url":"https://api.github.com/users/llevitis/events{/privacy}","received_events_url":"https://api.github.com/users/llevitis/received_events","type":"User","site_admin":false},"body":"This script serves as the first step to normalizing the mri_protocol. Some projects store comma-separated values for multiple fields, so `normalize_protocol_split_rows` creates arrays of unique combinations from each row and inserts new rows with unique values. It then deletes the original row containing comma-separated values. The subsequent step to fully normalizing the mri_protocol will be a 2nd PR containing a patch to replace all %_range columns with %_min & %_max columns and a script to populate the new columns. \r\n\r\nIMPORTANT NOTE: this should not be merged unless there are PR on the LORIS-MRI side to account for these changes and ready to be merged.","created_at":"2018-02-28T22:50:55Z","updated_at":"2018-03-12T19:24:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db13100f4a6b492903b612a6b2ff2bac11fcebb2","assignee":{"login":"sruthymathew123","id":23702452,"avatar_url":"https://avatars2.githubusercontent.com/u/23702452?v=4","gravatar_id":"","url":"https://api.github.com/users/sruthymathew123","html_url":"https://github.com/sruthymathew123","followers_url":"https://api.github.com/users/sruthymathew123/followers","following_url":"https://api.github.com/users/sruthymathew123/following{/other_user}","gists_url":"https://api.github.com/users/sruthymathew123/gists{/gist_id}","starred_url":"https://api.github.com/users/sruthymathew123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sruthymathew123/subscriptions","organizations_url":"https://api.github.com/users/sruthymathew123/orgs","repos_url":"https://api.github.com/users/sruthymathew123/repos","events_url":"https://api.github.com/users/sruthymathew123/events{/privacy}","received_events_url":"https://api.github.com/users/sruthymathew123/received_events","type":"User","site_admin":false},"assignees":[{"login":"sruthymathew123","id":23702452,"avatar_url":"https://avatars2.githubusercontent.com/u/23702452?v=4","gravatar_id":"","url":"https://api.github.com/users/sruthymathew123","html_url":"https://github.com/sruthymathew123","followers_url":"https://api.github.com/users/sruthymathew123/followers","following_url":"https://api.github.com/users/sruthymathew123/following{/other_user}","gists_url":"https://api.github.com/users/sruthymathew123/gists{/gist_id}","starred_url":"https://api.github.com/users/sruthymathew123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sruthymathew123/subscriptions","organizations_url":"https://api.github.com/users/sruthymathew123/orgs","repos_url":"https://api.github.com/users/sruthymathew123/repos","events_url":"https://api.github.com/users/sruthymathew123/events{/privacy}","received_events_url":"https://api.github.com/users/sruthymathew123/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"ridz1208","id":15268287,"avatar_url":"https://avatars3.githubusercontent.com/u/15268287?v=4","gravatar_id":"","url":"https://api.github.com/users/ridz1208","html_url":"https://github.com/ridz1208","followers_url":"https://api.github.com/users/ridz1208/followers","following_url":"https://api.github.com/users/ridz1208/following{/other_user}","gists_url":"https://api.github.com/users/ridz1208/gists{/gist_id}","starred_url":"https://api.github.com/users/ridz1208/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridz1208/subscriptions","organizations_url":"https://api.github.com/users/ridz1208/orgs","repos_url":"https://api.github.com/users/ridz1208/repos","events_url":"https://api.github.com/users/ridz1208/events{/privacy}","received_events_url":"https://api.github.com/users/ridz1208/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":520487238,"url":"https://api.github.com/repos/aces/Loris/labels/Blocked","name":"Blocked","color":"000000","default":false},{"id":152314516,"url":"https://api.github.com/repos/aces/Loris/labels/Cleanup","name":"Cleanup","color":"006b75","default":false},{"id":345188265,"url":"https://api.github.com/repos/aces/Loris/labels/Needs%20Work","name":"Needs Work","color":"eb6420","default":false},{"id":708895955,"url":"https://api.github.com/repos/aces/Loris/labels/[branch]%20minor","name":"[branch] minor","color":"996633","default":false}],"milestone":{"url":"https://api.github.com/repos/aces/Loris/milestones/25","html_url":"https://github.com/aces/Loris/milestone/25","labels_url":"https://api.github.com/repos/aces/Loris/milestones/25/labels","id":3151074,"number":25,"title":"19.2","description":"","creator":{"login":"driusan","id":498329,"avatar_url":"https://avatars0.githubusercontent.com/u/498329?v=4","gravatar_id":"","url":"https://api.github.com/users/driusan","html_url":"https://github.com/driusan","followers_url":"https://api.github.com/users/driusan/followers","following_url":"https://api.github.com/users/driusan/following{/other_user}","gists_url":"https://api.github.com/users/driusan/gists{/gist_id}","starred_url":"https://api.github.com/users/driusan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/driusan/subscriptions","organizations_url":"https://api.github.com/users/driusan/orgs","repos_url":"https://api.github.com/users/driusan/repos","events_url":"https://api.github.com/users/driusan/events{/privacy}","received_events_url":"https://api.github.com/users/driusan/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":1,"state":"open","created_at":"2018-02-28T16:13:17Z","updated_at":"2018-03-12T15:05:20Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/aces/Loris/pulls/3523/commits","review_comments_url":"https://api.github.com/repos/aces/Loris/pulls/3523/comments","review_comment_url":"https://api.github.com/repos/aces/Loris/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aces/Loris/issues/3523/comments","statuses_url":"https://api.github.com/repos/aces/Loris/statuses/6d66dc2dcb65bdb62eb45c432af4943c40e3adde","head":{"label":"llevitis:normalize-mri-protocol-v2","ref":"normalize-mri-protocol-v2","sha":"6d66dc2dcb65bdb62eb45c432af4943c40e3adde","user":{"login":"llevitis","id":17363738,"avatar_url":"https://avatars3.githubusercontent.com/u/17363738?v=4","gravatar_id":"","url":"https://api.github.com/users/llevitis","html_url":"https://github.com/llevitis","followers_url":"https://api.github.com/users/llevitis/followers","following_url":"https://api.github.com/users/llevitis/following{/other_user}","gists_url":"https://api.github.com/users/llevitis/gists{/gist_id}","starred_url":"https://api.github.com/users/llevitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llevitis/subscriptions","organizations_url":"https://api.github.com/users/llevitis/orgs","repos_url":"https://api.github.com/users/llevitis/repos","events_url":"https://api.github.com/users/llevitis/events{/privacy}","received_events_url":"https://api.github.com/users/llevitis/received_events","type":"User","site_admin":false},"repo":{"id":90892327,"name":"Loris","full_name":"llevitis/Loris","owner":{"login":"llevitis","id":17363738,"avatar_url":"https://avatars3.githubusercontent.com/u/17363738?v=4","gravatar_id":"","url":"https://api.github.com/users/llevitis","html_url":"https://github.com/llevitis","followers_url":"https://api.github.com/users/llevitis/followers","following_url":"https://api.github.com/users/llevitis/following{/other_user}","gists_url":"https://api.github.com/users/llevitis/gists{/gist_id}","starred_url":"https://api.github.com/users/llevitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llevitis/subscriptions","organizations_url":"https://api.github.com/users/llevitis/orgs","repos_url":"https://api.github.com/users/llevitis/repos","events_url":"https://api.github.com/users/llevitis/events{/privacy}","received_events_url":"https://api.github.com/users/llevitis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/llevitis/Loris","description":"LORIS is a web-accessible database solution for longitudinal multi-site studies.","fork":true,"url":"https://api.github.com/repos/llevitis/Loris","forks_url":"https://api.github.com/repos/llevitis/Loris/forks","keys_url":"https://api.github.com/repos/llevitis/Loris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/llevitis/Loris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/llevitis/Loris/teams","hooks_url":"https://api.github.com/repos/llevitis/Loris/hooks","issue_events_url":"https://api.github.com/repos/llevitis/Loris/issues/events{/number}","events_url":"https://api.github.com/repos/llevitis/Loris/events","assignees_url":"https://api.github.com/repos/llevitis/Loris/assignees{/user}","branches_url":"https://api.github.com/repos/llevitis/Loris/branches{/branch}","tags_url":"https://api.github.com/repos/llevitis/Loris/tags","blobs_url":"https://api.github.com/repos/llevitis/Loris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/llevitis/Loris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/llevitis/Loris/git/refs{/sha}","trees_url":"https://api.github.com/repos/llevitis/Loris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/llevitis/Loris/statuses/{sha}","languages_url":"https://api.github.com/repos/llevitis/Loris/languages","stargazers_url":"https://api.github.com/repos/llevitis/Loris/stargazers","contributors_url":"https://api.github.com/repos/llevitis/Loris/contributors","subscribers_url":"https://api.github.com/repos/llevitis/Loris/subscribers","subscription_url":"https://api.github.com/repos/llevitis/Loris/subscription","commits_url":"https://api.github.com/repos/llevitis/Loris/commits{/sha}","git_commits_url":"https://api.github.com/repos/llevitis/Loris/git/commits{/sha}","comments_url":"https://api.github.com/repos/llevitis/Loris/comments{/number}","issue_comment_url":"https://api.github.com/repos/llevitis/Loris/issues/comments{/number}","contents_url":"https://api.github.com/repos/llevitis/Loris/contents/{+path}","compare_url":"https://api.github.com/repos/llevitis/Loris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/llevitis/Loris/merges","archive_url":"https://api.github.com/repos/llevitis/Loris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/llevitis/Loris/downloads","issues_url":"https://api.github.com/repos/llevitis/Loris/issues{/number}","pulls_url":"https://api.github.com/repos/llevitis/Loris/pulls{/number}","milestones_url":"https://api.github.com/repos/llevitis/Loris/milestones{/number}","notifications_url":"https://api.github.com/repos/llevitis/Loris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/llevitis/Loris/labels{/name}","releases_url":"https://api.github.com/repos/llevitis/Loris/releases{/id}","deployments_url":"https://api.github.com/repos/llevitis/Loris/deployments","created_at":"2017-05-10T17:44:59Z","updated_at":"2017-05-10T17:45:03Z","pushed_at":"2018-03-11T21:51:13Z","git_url":"git://github.com/llevitis/Loris.git","ssh_url":"git@github.com:llevitis/Loris.git","clone_url":"https://github.com/llevitis/Loris.git","svn_url":"https://github.com/llevitis/Loris","homepage":"","size":80349,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"17.1-dev"}},"base":{"label":"aces:minor","ref":"minor","sha":"af6b47f35cbbc14db0dd390f4f44ba29b1b85347","user":{"login":"aces","id":472868,"avatar_url":"https://avatars2.githubusercontent.com/u/472868?v=4","gravatar_id":"","url":"https://api.github.com/users/aces","html_url":"https://github.com/aces","followers_url":"https://api.github.com/users/aces/followers","following_url":"https://api.github.com/users/aces/following{/other_user}","gists_url":"https://api.github.com/users/aces/gists{/gist_id}","starred_url":"https://api.github.com/users/aces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aces/subscriptions","organizations_url":"https://api.github.com/users/aces/orgs","repos_url":"https://api.github.com/users/aces/repos","events_url":"https://api.github.com/users/aces/events{/privacy}","received_events_url":"https://api.github.com/users/aces/received_events","type":"Organization","site_admin":false},"repo":{"id":1125630,"name":"Loris","full_name":"aces/Loris","owner":{"login":"aces","id":472868,"avatar_url":"https://avatars2.githubusercontent.com/u/472868?v=4","gravatar_id":"","url":"https://api.github.com/users/aces","html_url":"https://github.com/aces","followers_url":"https://api.github.com/users/aces/followers","following_url":"https://api.github.com/users/aces/following{/other_user}","gists_url":"https://api.github.com/users/aces/gists{/gist_id}","starred_url":"https://api.github.com/users/aces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aces/subscriptions","organizations_url":"https://api.github.com/users/aces/orgs","repos_url":"https://api.github.com/users/aces/repos","events_url":"https://api.github.com/users/aces/events{/privacy}","received_events_url":"https://api.github.com/users/aces/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aces/Loris","description":"LORIS is a web-accessible database solution for longitudinal multi-site studies.","fork":false,"url":"https://api.github.com/repos/aces/Loris","forks_url":"https://api.github.com/repos/aces/Loris/forks","keys_url":"https://api.github.com/repos/aces/Loris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aces/Loris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aces/Loris/teams","hooks_url":"https://api.github.com/repos/aces/Loris/hooks","issue_events_url":"https://api.github.com/repos/aces/Loris/issues/events{/number}","events_url":"https://api.github.com/repos/aces/Loris/events","assignees_url":"https://api.github.com/repos/aces/Loris/assignees{/user}","branches_url":"https://api.github.com/repos/aces/Loris/branches{/branch}","tags_url":"https://api.github.com/repos/aces/Loris/tags","blobs_url":"https://api.github.com/repos/aces/Loris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aces/Loris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aces/Loris/git/refs{/sha}","trees_url":"https://api.github.com/repos/aces/Loris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aces/Loris/statuses/{sha}","languages_url":"https://api.github.com/repos/aces/Loris/languages","stargazers_url":"https://api.github.com/repos/aces/Loris/stargazers","contributors_url":"https://api.github.com/repos/aces/Loris/contributors","subscribers_url":"https://api.github.com/repos/aces/Loris/subscribers","subscription_url":"https://api.github.com/repos/aces/Loris/subscription","commits_url":"https://api.github.com/repos/aces/Loris/commits{/sha}","git_commits_url":"https://api.github.com/repos/aces/Loris/git/commits{/sha}","comments_url":"https://api.github.com/repos/aces/Loris/comments{/number}","issue_comment_url":"https://api.github.com/repos/aces/Loris/issues/comments{/number}","contents_url":"https://api.github.com/repos/aces/Loris/contents/{+path}","compare_url":"https://api.github.com/repos/aces/Loris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aces/Loris/merges","archive_url":"https://api.github.com/repos/aces/Loris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aces/Loris/downloads","issues_url":"https://api.github.com/repos/aces/Loris/issues{/number}","pulls_url":"https://api.github.com/repos/aces/Loris/pulls{/number}","milestones_url":"https://api.github.com/repos/aces/Loris/milestones{/number}","notifications_url":"https://api.github.com/repos/aces/Loris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aces/Loris/labels{/name}","releases_url":"https://api.github.com/repos/aces/Loris/releases{/id}","deployments_url":"https://api.github.com/repos/aces/Loris/deployments","created_at":"2010-11-30T14:57:57Z","updated_at":"2018-03-12T13:47:01Z","pushed_at":"2018-03-12T19:06:35Z","git_url":"git://github.com/aces/Loris.git","ssh_url":"git@github.com:aces/Loris.git","clone_url":"https://github.com/aces/Loris.git","svn_url":"https://github.com/aces/Loris","homepage":"","size":75944,"stargazers_count":59,"watchers_count":59,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":84,"mirror_url":null,"archived":false,"open_issues_count":68,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":84,"open_issues":68,"watchers":59,"default_branch":"minor"}},"_links":{"self":{"href":"https://api.github.com/repos/aces/Loris/pulls/3523"},"html":{"href":"https://github.com/aces/Loris/pull/3523"},"issue":{"href":"https://api.github.com/repos/aces/Loris/issues/3523"},"comments":{"href":"https://api.github.com/repos/aces/Loris/issues/3523/comments"},"review_comments":{"href":"https://api.github.com/repos/aces/Loris/pulls/3523/comments"},"review_comment":{"href":"https://api.github.com/repos/aces/Loris/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aces/Loris/pulls/3523/commits"},"statuses":{"href":"https://api.github.com/repos/aces/Loris/statuses/6d66dc2dcb65bdb62eb45c432af4943c40e3adde"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"MounaSafiHarab"}}