{"action":"created","comment":{"url":"https://api.github.com/repos/AfricasVoices/REACH/pulls/comments/217111619","pull_request_review_id":154748474,"id":217111619,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNzExMTYxOQ==","diff_hunk":"@@ -0,0 +1,91 @@\n+import argparse\n+import sys\n+\n+from core_data_modules.traced_data.io import TracedDataJsonIO, TracedDataCSVIO\n+from lib.analysis_keys import AnalysisKeys\n+from lib.fold_data import FoldData\n+\n+if __name__ == \"__main__\":\n+    parser = argparse.ArgumentParser(description=\"Generates a file for analysis from the cleaned and coded shows \"\n+                                                 \"and survey responses\")\n+    parser.add_argument(\"user\", help=\"User launching this program\")\n+    parser.add_argument(\"messages_input_dir\", metavar=\"messages-input-dir\",\n+                        help=\"Path to a directory containing JSON files of responses to each of the shows in this \"\n+                             \"project. Each JSON file should contain a list of serialized TracedData objects\")\n+    parser.add_argument(\"survey_input_path\", metavar=\"survey-input-path\",\n+                        help=\"Path to a coded survey JSON file, containing a list of serialized TracedData objects\")\n+    parser.add_argument(\"json_output_path\", metavar=\"json-output-path\",\n+                        help=\"Path to a JSON file to write serialized TracedData items to after modification by this\"\n+                             \"pipeline stage\")\n+    parser.add_argument(\"csv_output_path\", metavar=\"csv-output-path\",\n+                        help=\"Path to a CSV file to write the summarised stats to\")\n+\n+    args = parser.parse_args()\n+    user = args.user\n+    data_input_path = args.survey_input_path\n+    json_output_path = args.json_output_path\n+    csv_output_path = args.csv_output_path\n+\n+    demog_keys = [\n+        \"district\",\n+        \"district_raw\",\n+        \"gender\",\n+        \"gender_raw\",\n+        \"urban_rural\",\n+        \"urban_rural_raw\",\n+        \"age\",\n+        \"age_raw\",\n+        \"assessment\",\n+        \"assessment_raw\",\n+        \"idp\",\n+        \"idp_raw\"\n+    ]\n+\n+    evaluation_keys = [\n+        \"involved\",\n+        \"involved_raw\",\n+        \"repeated\",\n+        \"repeated_raw\"\n+    ]\n+\n+    # Load data\n+    with open(data_input_path, \"r\") as f:\n+        data = TracedDataJsonIO.import_json_to_traced_data_iterable(f)\n+\n+    # Translate keys to final values for analysis\n+    show_keys = set()\n+    for td in data:\n+        AnalysisKeys.set_analysis_keys(user, td)\n+        AnalysisKeys.set_matrix_keys(\n+            user, td, show_keys, \"S07E01_Humanitarian_Priorities (Text) - esc4jmcna_activation_coded\",\n+            \"humanitarian_priorities\"\n+        )\n+    show_keys = list(show_keys)\n+    show_keys.sort()\n+\n+    # TODO: Handle STOP codes\n+\n+    group_by_fn = lambda td: td[\"avf_phone_id\"]\n+    equal_keys = [\"UID\"]\n+    equal_keys.extend(demog_keys)\n+    equal_keys.extend(evaluation_keys)\n+    concat_keys = [\"humanitarian_priorities_raw\"]\n+    matrix_keys = show_keys\n+\n+    # TODO: Output data before folding.\n+\n+    data = FoldData.fold(user, data, group_by_fn, equal_keys, concat_keys, matrix_keys)\n+\n+    # Export to CSV\n+    export_keys = [\"UID\"]\n+    export_keys.extend(show_keys)\n+    export_keys.append(\"humanitarian_priorities_raw\")","path":"analysis_file/analysis_file.py","position":82,"original_position":82,"commit_id":"62f8caa5dbd7e1f13d38b69729d7f30001523e60","original_commit_id":"62f8caa5dbd7e1f13d38b69729d7f30001523e60","user":{"login":"lukechurch","id":2978182,"node_id":"MDQ6VXNlcjI5NzgxODI=","avatar_url":"https://avatars1.githubusercontent.com/u/2978182?v=4","gravatar_id":"","url":"https://api.github.com/users/lukechurch","html_url":"https://github.com/lukechurch","followers_url":"https://api.github.com/users/lukechurch/followers","following_url":"https://api.github.com/users/lukechurch/following{/other_user}","gists_url":"https://api.github.com/users/lukechurch/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechurch/subscriptions","organizations_url":"https://api.github.com/users/lukechurch/orgs","repos_url":"https://api.github.com/users/lukechurch/repos","events_url":"https://api.github.com/users/lukechurch/events{/privacy}","received_events_url":"https://api.github.com/users/lukechurch/received_events","type":"User","site_admin":false},"body":"Ouch.","created_at":"2018-09-12T16:57:34Z","updated_at":"2018-09-12T16:57:35Z","html_url":"https://github.com/AfricasVoices/REACH/pull/6#discussion_r217111619","pull_request_url":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/AfricasVoices/REACH/pulls/comments/217111619"},"html":{"href":"https://github.com/AfricasVoices/REACH/pull/6#discussion_r217111619"},"pull_request":{"href":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6"}},"in_reply_to_id":217087374},"pull_request":{"url":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6","id":214581691,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0NTgxNjkx","html_url":"https://github.com/AfricasVoices/REACH/pull/6","diff_url":"https://github.com/AfricasVoices/REACH/pull/6.diff","patch_url":"https://github.com/AfricasVoices/REACH/pull/6.patch","issue_url":"https://api.github.com/repos/AfricasVoices/REACH/issues/6","number":6,"state":"open","locked":false,"title":"Analysis Stage","user":{"login":"as2388","id":7963608,"node_id":"MDQ6VXNlcjc5NjM2MDg=","avatar_url":"https://avatars0.githubusercontent.com/u/7963608?v=4","gravatar_id":"","url":"https://api.github.com/users/as2388","html_url":"https://github.com/as2388","followers_url":"https://api.github.com/users/as2388/followers","following_url":"https://api.github.com/users/as2388/following{/other_user}","gists_url":"https://api.github.com/users/as2388/gists{/gist_id}","starred_url":"https://api.github.com/users/as2388/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/as2388/subscriptions","organizations_url":"https://api.github.com/users/as2388/orgs","repos_url":"https://api.github.com/users/as2388/repos","events_url":"https://api.github.com/users/as2388/events{/privacy}","received_events_url":"https://api.github.com/users/as2388/received_events","type":"User","site_admin":false},"body":"Adds a first-draft analysis stage to REACH pipeline. There are still some TODOs in this stage to be addressed.\r\n\r\nReview #5 first.","created_at":"2018-09-11T10:14:35Z","updated_at":"2018-09-12T16:57:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbd64d6c2a48a80c3d056f2e516a9c1374bf2c6c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6/commits","review_comments_url":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6/comments","review_comment_url":"https://api.github.com/repos/AfricasVoices/REACH/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AfricasVoices/REACH/issues/6/comments","statuses_url":"https://api.github.com/repos/AfricasVoices/REACH/statuses/62f8caa5dbd7e1f13d38b69729d7f30001523e60","head":{"label":"AfricasVoices:analysis","ref":"analysis","sha":"62f8caa5dbd7e1f13d38b69729d7f30001523e60","user":{"login":"AfricasVoices","id":35370544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MzcwNTQ0","avatar_url":"https://avatars1.githubusercontent.com/u/35370544?v=4","gravatar_id":"","url":"https://api.github.com/users/AfricasVoices","html_url":"https://github.com/AfricasVoices","followers_url":"https://api.github.com/users/AfricasVoices/followers","following_url":"https://api.github.com/users/AfricasVoices/following{/other_user}","gists_url":"https://api.github.com/users/AfricasVoices/gists{/gist_id}","starred_url":"https://api.github.com/users/AfricasVoices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AfricasVoices/subscriptions","organizations_url":"https://api.github.com/users/AfricasVoices/orgs","repos_url":"https://api.github.com/users/AfricasVoices/repos","events_url":"https://api.github.com/users/AfricasVoices/events{/privacy}","received_events_url":"https://api.github.com/users/AfricasVoices/received_events","type":"Organization","site_admin":false},"repo":{"id":145681529,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU2ODE1Mjk=","name":"REACH","full_name":"AfricasVoices/REACH","owner":{"login":"AfricasVoices","id":35370544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MzcwNTQ0","avatar_url":"https://avatars1.githubusercontent.com/u/35370544?v=4","gravatar_id":"","url":"https://api.github.com/users/AfricasVoices","html_url":"https://github.com/AfricasVoices","followers_url":"https://api.github.com/users/AfricasVoices/followers","following_url":"https://api.github.com/users/AfricasVoices/following{/other_user}","gists_url":"https://api.github.com/users/AfricasVoices/gists{/gist_id}","starred_url":"https://api.github.com/users/AfricasVoices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AfricasVoices/subscriptions","organizations_url":"https://api.github.com/users/AfricasVoices/orgs","repos_url":"https://api.github.com/users/AfricasVoices/repos","events_url":"https://api.github.com/users/AfricasVoices/events{/privacy}","received_events_url":"https://api.github.com/users/AfricasVoices/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AfricasVoices/REACH","description":null,"fork":false,"url":"https://api.github.com/repos/AfricasVoices/REACH","forks_url":"https://api.github.com/repos/AfricasVoices/REACH/forks","keys_url":"https://api.github.com/repos/AfricasVoices/REACH/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AfricasVoices/REACH/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AfricasVoices/REACH/teams","hooks_url":"https://api.github.com/repos/AfricasVoices/REACH/hooks","issue_events_url":"https://api.github.com/repos/AfricasVoices/REACH/issues/events{/number}","events_url":"https://api.github.com/repos/AfricasVoices/REACH/events","assignees_url":"https://api.github.com/repos/AfricasVoices/REACH/assignees{/user}","branches_url":"https://api.github.com/repos/AfricasVoices/REACH/branches{/branch}","tags_url":"https://api.github.com/repos/AfricasVoices/REACH/tags","blobs_url":"https://api.github.com/repos/AfricasVoices/REACH/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AfricasVoices/REACH/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AfricasVoices/REACH/git/refs{/sha}","trees_url":"https://api.github.com/repos/AfricasVoices/REACH/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AfricasVoices/REACH/statuses/{sha}","languages_url":"https://api.github.com/repos/AfricasVoices/REACH/languages","stargazers_url":"https://api.github.com/repos/AfricasVoices/REACH/stargazers","contributors_url":"https://api.github.com/repos/AfricasVoices/REACH/contributors","subscribers_url":"https://api.github.com/repos/AfricasVoices/REACH/subscribers","subscription_url":"https://api.github.com/repos/AfricasVoices/REACH/subscription","commits_url":"https://api.github.com/repos/AfricasVoices/REACH/commits{/sha}","git_commits_url":"https://api.github.com/repos/AfricasVoices/REACH/git/commits{/sha}","comments_url":"https://api.github.com/repos/AfricasVoices/REACH/comments{/number}","issue_comment_url":"https://api.github.com/repos/AfricasVoices/REACH/issues/comments{/number}","contents_url":"https://api.github.com/repos/AfricasVoices/REACH/contents/{+path}","compare_url":"https://api.github.com/repos/AfricasVoices/REACH/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AfricasVoices/REACH/merges","archive_url":"https://api.github.com/repos/AfricasVoices/REACH/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AfricasVoices/REACH/downloads","issues_url":"https://api.github.com/repos/AfricasVoices/REACH/issues{/number}","pulls_url":"https://api.github.com/repos/AfricasVoices/REACH/pulls{/number}","milestones_url":"https://api.github.com/repos/AfricasVoices/REACH/milestones{/number}","notifications_url":"https://api.github.com/repos/AfricasVoices/REACH/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AfricasVoices/REACH/labels{/name}","releases_url":"https://api.github.com/repos/AfricasVoices/REACH/releases{/id}","deployments_url":"https://api.github.com/repos/AfricasVoices/REACH/deployments","created_at":"2018-08-22T08:45:18Z","updated_at":"2018-09-10T09:08:01Z","pushed_at":"2018-09-12T10:12:48Z","git_url":"git://github.com/AfricasVoices/REACH.git","ssh_url":"git@github.com:AfricasVoices/REACH.git","clone_url":"https://github.com/AfricasVoices/REACH.git","svn_url":"https://github.com/AfricasVoices/REACH","homepage":null,"size":145,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"AfricasVoices:master","ref":"master","sha":"4052485755bfaf51852c3af77ef09dd493563c5e","user":{"login":"AfricasVoices","id":35370544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MzcwNTQ0","avatar_url":"https://avatars1.githubusercontent.com/u/35370544?v=4","gravatar_id":"","url":"https://api.github.com/users/AfricasVoices","html_url":"https://github.com/AfricasVoices","followers_url":"https://api.github.com/users/AfricasVoices/followers","following_url":"https://api.github.com/users/AfricasVoices/following{/other_user}","gists_url":"https://api.github.com/users/AfricasVoices/gists{/gist_id}","starred_url":"https://api.github.com/users/AfricasVoices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AfricasVoices/subscriptions","organizations_url":"https://api.github.com/users/AfricasVoices/orgs","repos_url":"https://api.github.com/users/AfricasVoices/repos","events_url":"https://api.github.com/users/AfricasVoices/events{/privacy}","received_events_url":"https://api.github.com/users/AfricasVoices/received_events","type":"Organization","site_admin":false},"repo":{"id":145681529,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU2ODE1Mjk=","name":"REACH","full_name":"AfricasVoices/REACH","owner":{"login":"AfricasVoices","id":35370544,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1MzcwNTQ0","avatar_url":"https://avatars1.githubusercontent.com/u/35370544?v=4","gravatar_id":"","url":"https://api.github.com/users/AfricasVoices","html_url":"https://github.com/AfricasVoices","followers_url":"https://api.github.com/users/AfricasVoices/followers","following_url":"https://api.github.com/users/AfricasVoices/following{/other_user}","gists_url":"https://api.github.com/users/AfricasVoices/gists{/gist_id}","starred_url":"https://api.github.com/users/AfricasVoices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AfricasVoices/subscriptions","organizations_url":"https://api.github.com/users/AfricasVoices/orgs","repos_url":"https://api.github.com/users/AfricasVoices/repos","events_url":"https://api.github.com/users/AfricasVoices/events{/privacy}","received_events_url":"https://api.github.com/users/AfricasVoices/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AfricasVoices/REACH","description":null,"fork":false,"url":"https://api.github.com/repos/AfricasVoices/REACH","forks_url":"https://api.github.com/repos/AfricasVoices/REACH/forks","keys_url":"https://api.github.com/repos/AfricasVoices/REACH/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AfricasVoices/REACH/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AfricasVoices/REACH/teams","hooks_url":"https://api.github.com/repos/AfricasVoices/REACH/hooks","issue_events_url":"https://api.github.com/repos/AfricasVoices/REACH/issues/events{/number}","events_url":"https://api.github.com/repos/AfricasVoices/REACH/events","assignees_url":"https://api.github.com/repos/AfricasVoices/REACH/assignees{/user}","branches_url":"https://api.github.com/repos/AfricasVoices/REACH/branches{/branch}","tags_url":"https://api.github.com/repos/AfricasVoices/REACH/tags","blobs_url":"https://api.github.com/repos/AfricasVoices/REACH/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AfricasVoices/REACH/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AfricasVoices/REACH/git/refs{/sha}","trees_url":"https://api.github.com/repos/AfricasVoices/REACH/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AfricasVoices/REACH/statuses/{sha}","languages_url":"https://api.github.com/repos/AfricasVoices/REACH/languages","stargazers_url":"https://api.github.com/repos/AfricasVoices/REACH/stargazers","contributors_url":"https://api.github.com/repos/AfricasVoices/REACH/contributors","subscribers_url":"https://api.github.com/repos/AfricasVoices/REACH/subscribers","subscription_url":"https://api.github.com/repos/AfricasVoices/REACH/subscription","commits_url":"https://api.github.com/repos/AfricasVoices/REACH/commits{/sha}","git_commits_url":"https://api.github.com/repos/AfricasVoices/REACH/git/commits{/sha}","comments_url":"https://api.github.com/repos/AfricasVoices/REACH/comments{/number}","issue_comment_url":"https://api.github.com/repos/AfricasVoices/REACH/issues/comments{/number}","contents_url":"https://api.github.com/repos/AfricasVoices/REACH/contents/{+path}","compare_url":"https://api.github.com/repos/AfricasVoices/REACH/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AfricasVoices/REACH/merges","archive_url":"https://api.github.com/repos/AfricasVoices/REACH/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AfricasVoices/REACH/downloads","issues_url":"https://api.github.com/repos/AfricasVoices/REACH/issues{/number}","pulls_url":"https://api.github.com/repos/AfricasVoices/REACH/pulls{/number}","milestones_url":"https://api.github.com/repos/AfricasVoices/REACH/milestones{/number}","notifications_url":"https://api.github.com/repos/AfricasVoices/REACH/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AfricasVoices/REACH/labels{/name}","releases_url":"https://api.github.com/repos/AfricasVoices/REACH/releases{/id}","deployments_url":"https://api.github.com/repos/AfricasVoices/REACH/deployments","created_at":"2018-08-22T08:45:18Z","updated_at":"2018-09-10T09:08:01Z","pushed_at":"2018-09-12T10:12:48Z","git_url":"git://github.com/AfricasVoices/REACH.git","ssh_url":"git@github.com:AfricasVoices/REACH.git","clone_url":"https://github.com/AfricasVoices/REACH.git","svn_url":"https://github.com/AfricasVoices/REACH","homepage":null,"size":145,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6"},"html":{"href":"https://github.com/AfricasVoices/REACH/pull/6"},"issue":{"href":"https://api.github.com/repos/AfricasVoices/REACH/issues/6"},"comments":{"href":"https://api.github.com/repos/AfricasVoices/REACH/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/AfricasVoices/REACH/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AfricasVoices/REACH/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/AfricasVoices/REACH/statuses/62f8caa5dbd7e1f13d38b69729d7f30001523e60"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"lukechurch"}}