{"action":"created","comment":{"url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/comments/232509175","pull_request_review_id":173719957,"id":232509175,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjUwOTE3NQ==","diff_hunk":"@@ -18,13 +18,14 @@ class Restroom < ApplicationRecord\n   ignoring: :accents\n \n   validates :name, :street, :city, :state, presence: true\n+  validates :street, uniqueness: {scope: [:city, :state], message: \"is already registered\"}\n \n   geocoded_by :full_address\n-  after_validation :perform_geocoding\n+  before_validation :perform_geocoding, if: ->(obj){ obj.full_address.present? }\n+  before_validation :reverse_geocode, if: ->(obj){ obj.full_address.present? }","path":"app/models/restroom.rb","position":9,"original_position":9,"commit_id":"9a53a7d933018aafa84f994fbda0209dbd71af7d","original_commit_id":"9a53a7d933018aafa84f994fbda0209dbd71af7d","user":{"login":"cllns","id":632942,"node_id":"MDQ6VXNlcjYzMjk0Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/632942?v=4","gravatar_id":"","url":"https://api.github.com/users/cllns","html_url":"https://github.com/cllns","followers_url":"https://api.github.com/users/cllns/followers","following_url":"https://api.github.com/users/cllns/following{/other_user}","gists_url":"https://api.github.com/users/cllns/gists{/gist_id}","starred_url":"https://api.github.com/users/cllns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cllns/subscriptions","organizations_url":"https://api.github.com/users/cllns/orgs","repos_url":"https://api.github.com/users/cllns/repos","events_url":"https://api.github.com/users/cllns/events{/privacy}","received_events_url":"https://api.github.com/users/cllns/received_events","type":"User","site_admin":false},"body":"I think you can DRY this and make it a little simpler by using a method here.\r\nhttps://guides.rubyonrails.org/active_record_validations.html#using-a-symbol-with-if-and-unless\r\n\r\n```ruby\r\nbefore_validation :perform_geocoding, if: :require_geocoding?\r\n```\r\n```ruby\r\ndef require_geocoding?\r\n  full_address.present?\r\nend\r\n```\r\n\r\nAlso, `full_address` should be reimplemented, since right now it always returns a string (so this condition is always `true`. \r\n\r\nInstead of:\r\n```ruby\r\ndef full_address\r\n  \"#{street}, #{city}, #{state}, #{country}\"\r\nend\r\n```\r\n\r\n```ruby\r\ndef full_address\r\n  [street, city, state, country].compact.join(\",\")\r\nend\r\n```\r\n(I think this is better than showing empty values, but \"123 Main Street, USA\" doesn't really make sense either.)","created_at":"2018-11-11T23:08:09Z","updated_at":"2018-11-11T23:08:18Z","html_url":"https://github.com/RefugeRestrooms/refugerestrooms/pull/518#discussion_r232509175","pull_request_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/comments/232509175"},"html":{"href":"https://github.com/RefugeRestrooms/refugerestrooms/pull/518#discussion_r232509175"},"pull_request":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518"}}},"pull_request":{"url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518","id":222745544,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNzQ1NTQ0","html_url":"https://github.com/RefugeRestrooms/refugerestrooms/pull/518","diff_url":"https://github.com/RefugeRestrooms/refugerestrooms/pull/518.diff","patch_url":"https://github.com/RefugeRestrooms/refugerestrooms/pull/518.patch","issue_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues/518","number":518,"state":"open","locked":false,"title":"Store reverse geo-coded address & force unique addresses","user":{"login":"tcmal","id":4183876,"node_id":"MDQ6VXNlcjQxODM4NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/4183876?v=4","gravatar_id":"","url":"https://api.github.com/users/tcmal","html_url":"https://github.com/tcmal","followers_url":"https://api.github.com/users/tcmal/followers","following_url":"https://api.github.com/users/tcmal/following{/other_user}","gists_url":"https://api.github.com/users/tcmal/gists{/gist_id}","starred_url":"https://api.github.com/users/tcmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcmal/subscriptions","organizations_url":"https://api.github.com/users/tcmal/orgs","repos_url":"https://api.github.com/users/tcmal/repos","events_url":"https://api.github.com/users/tcmal/events{/privacy}","received_events_url":"https://api.github.com/users/tcmal/received_events","type":"User","site_admin":false},"body":"# Context\r\n\r\n- Fixes #399\r\n\r\nGenerally, this makes the data more consistent, however this relies more on the geocode lookup being correct for what the user puts in. It might be a good idea to force the user to preview (via google maps) before they can submit a restroom, or to use a proper address lookup. Thoughts?\r\n\r\n# Summary of Changes\r\n\r\nRestrooms will now populate the geocode, then set the address fields to the address from a reverse lookup before validation.\r\n\r\nThe address field must be unique. This is only enforced in the activerecord model & not the database schema, meaning it won't complain about existing records / manually added records.\r\n\r\nAdded a task that iterates over each restroom and re-populates the address from a reverse geocode lookup (`db:reverse_geocode` / `db:reverse_geocode[dry_run]`)","created_at":"2018-10-14T21:49:19Z","updated_at":"2018-11-11T23:08:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63eda9b019762d8a75cb6877a7999ab83b7a6bf1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1074441377,"node_id":"MDU6TGFiZWwxMDc0NDQxMzc3","url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/labels/Hacktoberfest","name":"Hacktoberfest","color":"FDA365","default":false},{"id":784120585,"node_id":"MDU6TGFiZWw3ODQxMjA1ODU=","url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/labels/Ready%20for%20Review","name":"Ready for Review","color":"fbca04","default":false},{"id":67939696,"node_id":"MDU6TGFiZWw2NzkzOTY5Ng==","url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518/commits","review_comments_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518/comments","review_comment_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues/518/comments","statuses_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/statuses/9a53a7d933018aafa84f994fbda0209dbd71af7d","head":{"label":"tcmal:399-duplicates","ref":"399-duplicates","sha":"9a53a7d933018aafa84f994fbda0209dbd71af7d","user":{"login":"tcmal","id":4183876,"node_id":"MDQ6VXNlcjQxODM4NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/4183876?v=4","gravatar_id":"","url":"https://api.github.com/users/tcmal","html_url":"https://github.com/tcmal","followers_url":"https://api.github.com/users/tcmal/followers","following_url":"https://api.github.com/users/tcmal/following{/other_user}","gists_url":"https://api.github.com/users/tcmal/gists{/gist_id}","starred_url":"https://api.github.com/users/tcmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcmal/subscriptions","organizations_url":"https://api.github.com/users/tcmal/orgs","repos_url":"https://api.github.com/users/tcmal/repos","events_url":"https://api.github.com/users/tcmal/events{/privacy}","received_events_url":"https://api.github.com/users/tcmal/received_events","type":"User","site_admin":false},"repo":{"id":153007066,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMwMDcwNjY=","name":"refugerestrooms","full_name":"tcmal/refugerestrooms","private":false,"owner":{"login":"tcmal","id":4183876,"node_id":"MDQ6VXNlcjQxODM4NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/4183876?v=4","gravatar_id":"","url":"https://api.github.com/users/tcmal","html_url":"https://github.com/tcmal","followers_url":"https://api.github.com/users/tcmal/followers","following_url":"https://api.github.com/users/tcmal/following{/other_user}","gists_url":"https://api.github.com/users/tcmal/gists{/gist_id}","starred_url":"https://api.github.com/users/tcmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcmal/subscriptions","organizations_url":"https://api.github.com/users/tcmal/orgs","repos_url":"https://api.github.com/users/tcmal/repos","events_url":"https://api.github.com/users/tcmal/events{/privacy}","received_events_url":"https://api.github.com/users/tcmal/received_events","type":"User","site_admin":false},"html_url":"https://github.com/tcmal/refugerestrooms","description":"REFUGE restrooms indexes and maps safe restroom locations for trans, intersex, and gender nonconforming individuals. ","fork":true,"url":"https://api.github.com/repos/tcmal/refugerestrooms","forks_url":"https://api.github.com/repos/tcmal/refugerestrooms/forks","keys_url":"https://api.github.com/repos/tcmal/refugerestrooms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tcmal/refugerestrooms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tcmal/refugerestrooms/teams","hooks_url":"https://api.github.com/repos/tcmal/refugerestrooms/hooks","issue_events_url":"https://api.github.com/repos/tcmal/refugerestrooms/issues/events{/number}","events_url":"https://api.github.com/repos/tcmal/refugerestrooms/events","assignees_url":"https://api.github.com/repos/tcmal/refugerestrooms/assignees{/user}","branches_url":"https://api.github.com/repos/tcmal/refugerestrooms/branches{/branch}","tags_url":"https://api.github.com/repos/tcmal/refugerestrooms/tags","blobs_url":"https://api.github.com/repos/tcmal/refugerestrooms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tcmal/refugerestrooms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tcmal/refugerestrooms/git/refs{/sha}","trees_url":"https://api.github.com/repos/tcmal/refugerestrooms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tcmal/refugerestrooms/statuses/{sha}","languages_url":"https://api.github.com/repos/tcmal/refugerestrooms/languages","stargazers_url":"https://api.github.com/repos/tcmal/refugerestrooms/stargazers","contributors_url":"https://api.github.com/repos/tcmal/refugerestrooms/contributors","subscribers_url":"https://api.github.com/repos/tcmal/refugerestrooms/subscribers","subscription_url":"https://api.github.com/repos/tcmal/refugerestrooms/subscription","commits_url":"https://api.github.com/repos/tcmal/refugerestrooms/commits{/sha}","git_commits_url":"https://api.github.com/repos/tcmal/refugerestrooms/git/commits{/sha}","comments_url":"https://api.github.com/repos/tcmal/refugerestrooms/comments{/number}","issue_comment_url":"https://api.github.com/repos/tcmal/refugerestrooms/issues/comments{/number}","contents_url":"https://api.github.com/repos/tcmal/refugerestrooms/contents/{+path}","compare_url":"https://api.github.com/repos/tcmal/refugerestrooms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tcmal/refugerestrooms/merges","archive_url":"https://api.github.com/repos/tcmal/refugerestrooms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tcmal/refugerestrooms/downloads","issues_url":"https://api.github.com/repos/tcmal/refugerestrooms/issues{/number}","pulls_url":"https://api.github.com/repos/tcmal/refugerestrooms/pulls{/number}","milestones_url":"https://api.github.com/repos/tcmal/refugerestrooms/milestones{/number}","notifications_url":"https://api.github.com/repos/tcmal/refugerestrooms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tcmal/refugerestrooms/labels{/name}","releases_url":"https://api.github.com/repos/tcmal/refugerestrooms/releases{/id}","deployments_url":"https://api.github.com/repos/tcmal/refugerestrooms/deployments","created_at":"2018-10-14T18:45:56Z","updated_at":"2018-10-14T18:45:59Z","pushed_at":"2018-10-14T21:38:39Z","git_url":"git://github.com/tcmal/refugerestrooms.git","ssh_url":"git@github.com:tcmal/refugerestrooms.git","clone_url":"https://github.com/tcmal/refugerestrooms.git","svn_url":"https://github.com/tcmal/refugerestrooms","homepage":"http://www.refugerestrooms.org","size":18984,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"RefugeRestrooms:develop","ref":"develop","sha":"f444783543b4d1e310c3c89415cdc7cbcbb208da","user":{"login":"RefugeRestrooms","id":7143123,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcxNDMxMjM=","avatar_url":"https://avatars2.githubusercontent.com/u/7143123?v=4","gravatar_id":"","url":"https://api.github.com/users/RefugeRestrooms","html_url":"https://github.com/RefugeRestrooms","followers_url":"https://api.github.com/users/RefugeRestrooms/followers","following_url":"https://api.github.com/users/RefugeRestrooms/following{/other_user}","gists_url":"https://api.github.com/users/RefugeRestrooms/gists{/gist_id}","starred_url":"https://api.github.com/users/RefugeRestrooms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RefugeRestrooms/subscriptions","organizations_url":"https://api.github.com/users/RefugeRestrooms/orgs","repos_url":"https://api.github.com/users/RefugeRestrooms/repos","events_url":"https://api.github.com/users/RefugeRestrooms/events{/privacy}","received_events_url":"https://api.github.com/users/RefugeRestrooms/received_events","type":"Organization","site_admin":false},"repo":{"id":14741294,"node_id":"MDEwOlJlcG9zaXRvcnkxNDc0MTI5NA==","name":"refugerestrooms","full_name":"RefugeRestrooms/refugerestrooms","private":false,"owner":{"login":"RefugeRestrooms","id":7143123,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcxNDMxMjM=","avatar_url":"https://avatars2.githubusercontent.com/u/7143123?v=4","gravatar_id":"","url":"https://api.github.com/users/RefugeRestrooms","html_url":"https://github.com/RefugeRestrooms","followers_url":"https://api.github.com/users/RefugeRestrooms/followers","following_url":"https://api.github.com/users/RefugeRestrooms/following{/other_user}","gists_url":"https://api.github.com/users/RefugeRestrooms/gists{/gist_id}","starred_url":"https://api.github.com/users/RefugeRestrooms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RefugeRestrooms/subscriptions","organizations_url":"https://api.github.com/users/RefugeRestrooms/orgs","repos_url":"https://api.github.com/users/RefugeRestrooms/repos","events_url":"https://api.github.com/users/RefugeRestrooms/events{/privacy}","received_events_url":"https://api.github.com/users/RefugeRestrooms/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/RefugeRestrooms/refugerestrooms","description":"REFUGE restrooms indexes and maps safe restroom locations for trans, intersex, and gender nonconforming individuals. ","fork":false,"url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms","forks_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/forks","keys_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/teams","hooks_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/hooks","issue_events_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues/events{/number}","events_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/events","assignees_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/assignees{/user}","branches_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/branches{/branch}","tags_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/tags","blobs_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/git/refs{/sha}","trees_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/statuses/{sha}","languages_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/languages","stargazers_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/stargazers","contributors_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/contributors","subscribers_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/subscribers","subscription_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/subscription","commits_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/commits{/sha}","git_commits_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/git/commits{/sha}","comments_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/comments{/number}","issue_comment_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues/comments{/number}","contents_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/contents/{+path}","compare_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/merges","archive_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/downloads","issues_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues{/number}","pulls_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls{/number}","milestones_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/milestones{/number}","notifications_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/labels{/name}","releases_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/releases{/id}","deployments_url":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/deployments","created_at":"2013-11-27T08:23:31Z","updated_at":"2018-11-11T19:01:10Z","pushed_at":"2018-11-11T19:19:05Z","git_url":"git://github.com/RefugeRestrooms/refugerestrooms.git","ssh_url":"git@github.com:RefugeRestrooms/refugerestrooms.git","clone_url":"https://github.com/RefugeRestrooms/refugerestrooms.git","svn_url":"https://github.com/RefugeRestrooms/refugerestrooms","homepage":"http://www.refugerestrooms.org","size":19033,"stargazers_count":618,"watchers_count":618,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":217,"mirror_url":null,"archived":false,"open_issues_count":63,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":217,"open_issues":63,"watchers":618,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518"},"html":{"href":"https://github.com/RefugeRestrooms/refugerestrooms/pull/518"},"issue":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues/518"},"comments":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/issues/518/comments"},"review_comments":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518/comments"},"review_comment":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/pulls/518/commits"},"statuses":{"href":"https://api.github.com/repos/RefugeRestrooms/refugerestrooms/statuses/9a53a7d933018aafa84f994fbda0209dbd71af7d"}},"author_association":"NONE"}}
{"actor":{"display_login":"cllns"}}