{"action":"created","comment":{"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments/174541861","pull_request_review_id":103918166,"id":174541861,"diff_hunk":"@@ -33,30 +33,43 @@ def attribute_mappings(entry, mapping)\n             attrs = entry['attributes']\n             mapped_attrs = { 'address' => {}, 'services' => {} }\n             mapping.slice('unique_id', 'name', 'classification', 'website').each do |key, value|\n-              mapped_attrs[key] = attrs[value]\n+              mapped_attrs[key] = clean(attrs[value])\n             end\n             %w[hours access feedback phone].each do |name|\n               mapped_attrs[name] = nested(mapping[name], attrs)\n             end\n             mapped_attrs['address']['physical'] = nested(mapping['physical'], attrs)\n             mapped_attrs['address']['mailing'] = nested(mapping['mailing'], attrs)\n-            mapped_attrs['services']['benefits'] = nested(mapping['benefits'], attrs)\n-            mapped_attrs['services']['last_updated'] = services_date(attrs)\n-            mapped_attrs['services']['health'] = services_from_gis(mapping['services'], attrs)\n-\n-            mapped_attrs.merge!(\n-              'lat' => entry['geometry']['y'],\n-              'long' => entry['geometry']['x']\n-            )\n+            if mapping['benefits']\n+              mapped_attrs['services']['benefits'] = {\n+                'standard' => clean_benefits(nested(mapping['benefits'], attrs)),\n+                'other' => attrs['Other_Services']\n+              }\n+\n+            end\n+            mapped_attrs['services']['last_updated'] = services_date(attrs) if mapping['services']\n+            mapped_attrs['services']['health'] = services_from_gis(mapping['services'], attrs) if mapping['services']\n+\n+            mapped_attrs.merge!('lat' => entry['geometry']['y'], 'long' => entry['geometry']['x'])\n           end\n \n           def nested(item, attrs)\n-            return unless item\n+            return {} unless item\n             item.each_with_object({}) do |(key, value), hash|\n-              hash[key] = value.respond_to?(:call) ? value.call(attrs) : attrs[value]\n+              hash[key] = value.respond_to?(:call) ? value.call(attrs) : clean(attrs[value])\n+            end\n+          end\n+\n+          def clean_benefits(benefits_hash)\n+            benefits_hash.each_with_object([]) do |(key, value), list|\n+              list << key if value == 'YES'\n             end\n           end\n \n+          def clean(value)\n+            value.respond_to?(:strip) ? value.strip : value\n+          end\n+\n           def services_date(attrs)\n             Date.strptime(attrs['FacilityDataDate'], '%m-%d-%Y').iso8601 if attrs['FacilityDataDate']","path":"lib/common/client/middleware/response/facility_parser.rb","position":53,"original_position":53,"commit_id":"1eb386871df0a765ded053d698ccae990b650f7f","original_commit_id":"1eb386871df0a765ded053d698ccae990b650f7f","user":{"login":"dhall","id":299180,"avatar_url":"https://avatars3.githubusercontent.com/u/299180?v=4","gravatar_id":"","url":"https://api.github.com/users/dhall","html_url":"https://github.com/dhall","followers_url":"https://api.github.com/users/dhall/followers","following_url":"https://api.github.com/users/dhall/following{/other_user}","gists_url":"https://api.github.com/users/dhall/gists{/gist_id}","starred_url":"https://api.github.com/users/dhall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhall/subscriptions","organizations_url":"https://api.github.com/users/dhall/orgs","repos_url":"https://api.github.com/users/dhall/repos","events_url":"https://api.github.com/users/dhall/events{/privacy}","received_events_url":"https://api.github.com/users/dhall/received_events","type":"User","site_admin":false},"body":"I don't know the answer (yet) but I can dig into the data.. This was how we currently handle the service dates.","created_at":"2018-03-14T17:21:39Z","updated_at":"2018-03-14T17:21:39Z","html_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1768#discussion_r174541861","pull_request_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments/174541861"},"html":{"href":"https://github.com/department-of-veterans-affairs/vets-api/pull/1768#discussion_r174541861"},"pull_request":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768"}},"in_reply_to_id":174521794},"pull_request":{"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768","id":174644801,"html_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1768","diff_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1768.diff","patch_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1768.patch","issue_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1768","number":1768,"state":"open","locked":false,"title":"parsing changes to make records match","user":{"login":"dhall","id":299180,"avatar_url":"https://avatars3.githubusercontent.com/u/299180?v=4","gravatar_id":"","url":"https://api.github.com/users/dhall","html_url":"https://github.com/dhall","followers_url":"https://api.github.com/users/dhall/followers","following_url":"https://api.github.com/users/dhall/following{/other_user}","gists_url":"https://api.github.com/users/dhall/gists{/gist_id}","starred_url":"https://api.github.com/users/dhall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhall/subscriptions","organizations_url":"https://api.github.com/users/dhall/orgs","repos_url":"https://api.github.com/users/dhall/repos","events_url":"https://api.github.com/users/dhall/events{/privacy}","received_events_url":"https://api.github.com/users/dhall/received_events","type":"User","site_admin":false},"body":"These changes came out of my field by field comparison of the data. I did this by setting up a temporary controller action that pulled facility data from the pg database. This allowed me to run queries against the existing controller and my temporary controller and compare.","created_at":"2018-03-13T12:30:47Z","updated_at":"2018-03-14T17:21:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f391988c43914403c8bc4bb577557c62c62d56b","assignee":null,"assignees":[],"requested_reviewers":[{"login":"U-DON","id":1067024,"avatar_url":"https://avatars3.githubusercontent.com/u/1067024?v=4","gravatar_id":"","url":"https://api.github.com/users/U-DON","html_url":"https://github.com/U-DON","followers_url":"https://api.github.com/users/U-DON/followers","following_url":"https://api.github.com/users/U-DON/following{/other_user}","gists_url":"https://api.github.com/users/U-DON/gists{/gist_id}","starred_url":"https://api.github.com/users/U-DON/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/U-DON/subscriptions","organizations_url":"https://api.github.com/users/U-DON/orgs","repos_url":"https://api.github.com/users/U-DON/repos","events_url":"https://api.github.com/users/U-DON/events{/privacy}","received_events_url":"https://api.github.com/users/U-DON/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768/commits","review_comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768/comments","review_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1768/comments","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/1eb386871df0a765ded053d698ccae990b650f7f","head":{"label":"department-of-veterans-affairs:9112_validation_compare_ArcGIS_data_against_local_db_cache","ref":"9112_validation_compare_ArcGIS_data_against_local_db_cache","sha":"1eb386871df0a765ded053d698ccae990b650f7f","user":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"repo":{"id":62409417,"name":"vets-api","full_name":"department-of-veterans-affairs/vets-api","owner":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/department-of-veterans-affairs/vets-api","description":"API for vets.gov","fork":false,"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api","forks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/forks","keys_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/teams","hooks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/hooks","issue_events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/events{/number}","events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/events","assignees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/assignees{/user}","branches_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/branches{/branch}","tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/tags","blobs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/{sha}","languages_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/languages","stargazers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/stargazers","contributors_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contributors","subscribers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscribers","subscription_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscription","commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contents/{+path}","compare_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/merges","archive_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/downloads","issues_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues{/number}","pulls_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls{/number}","milestones_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/milestones{/number}","notifications_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/labels{/name}","releases_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/releases{/id}","deployments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/deployments","created_at":"2016-07-01T17:33:19Z","updated_at":"2018-03-14T17:06:04Z","pushed_at":"2018-03-14T17:06:58Z","git_url":"git://github.com/department-of-veterans-affairs/vets-api.git","ssh_url":"git@github.com:department-of-veterans-affairs/vets-api.git","clone_url":"https://github.com/department-of-veterans-affairs/vets-api.git","svn_url":"https://github.com/department-of-veterans-affairs/vets-api","homepage":null,"size":65503,"stargazers_count":25,"watchers_count":25,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":12,"open_issues":15,"watchers":25,"default_branch":"master"}},"base":{"label":"department-of-veterans-affairs:master","ref":"master","sha":"7b50f9f572402bf1abf9ca95c7a54f22621988a5","user":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"repo":{"id":62409417,"name":"vets-api","full_name":"department-of-veterans-affairs/vets-api","owner":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/department-of-veterans-affairs/vets-api","description":"API for vets.gov","fork":false,"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api","forks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/forks","keys_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/teams","hooks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/hooks","issue_events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/events{/number}","events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/events","assignees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/assignees{/user}","branches_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/branches{/branch}","tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/tags","blobs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/{sha}","languages_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/languages","stargazers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/stargazers","contributors_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contributors","subscribers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscribers","subscription_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscription","commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contents/{+path}","compare_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/merges","archive_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/downloads","issues_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues{/number}","pulls_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls{/number}","milestones_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/milestones{/number}","notifications_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/labels{/name}","releases_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/releases{/id}","deployments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/deployments","created_at":"2016-07-01T17:33:19Z","updated_at":"2018-03-14T17:06:04Z","pushed_at":"2018-03-14T17:06:58Z","git_url":"git://github.com/department-of-veterans-affairs/vets-api.git","ssh_url":"git@github.com:department-of-veterans-affairs/vets-api.git","clone_url":"https://github.com/department-of-veterans-affairs/vets-api.git","svn_url":"https://github.com/department-of-veterans-affairs/vets-api","homepage":null,"size":65503,"stargazers_count":25,"watchers_count":25,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":12,"open_issues":15,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768"},"html":{"href":"https://github.com/department-of-veterans-affairs/vets-api/pull/1768"},"issue":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1768"},"comments":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1768/comments"},"review_comments":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768/comments"},"review_comment":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1768/commits"},"statuses":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/1eb386871df0a765ded053d698ccae990b650f7f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dhall"}}