-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
399 duplicates #529
Open
mi-wood
wants to merge
12
commits into
develop
Choose a base branch
from
399-duplicates
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
399 duplicates #529
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
34aab54
Reverse Geocode address when validating (improves consistency)
bcbca57
Force address to be unique (Fixes #399)
7edbdd3
Add new rake task to reverse geocode all existing restrooms.
9a53a7d
Only perform geocoding if adress is present
3faf8e4
Merge branch 'develop' of https://github.com/RefugeRestrooms/refugere…
30875ef
Minor refactoring/code style improvements
708a75f
Merge pull request #518 from tcmal/399-duplicates
mi-wood 90729fe
use (obj)
mi-wood 1d754c5
disable validation for seeding
mi-wood 2e89406
block validation during testing
mi-wood 2a53c72
Add test for restroom reverse-geocoding.
f0dcfae
Merge pull request #538 from tcmal/399-duplicates
mi-wood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
Restroom.transaction do | ||
CSV.foreach('db/export.csv') do |row| | ||
Restroom.create( | ||
restroom = Restroom.new( | ||
:name => row[1], | ||
:street => row[3], | ||
:city => row[4], | ||
|
@@ -21,7 +21,8 @@ | |
:comment => row[12], | ||
:latitude => row[8], | ||
:longitude => row[9], | ||
:country => row[6] | ||
:country => row[6], | ||
) | ||
restroom.save(validate: false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignoring validation during seeding seems reasonable, since those don't really change ever. |
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace :db do | ||
desc "Reverse geocode each restroom's address (use db:reverse_geocode[dry_run] to preview changes)" | ||
task :reverse_geocode, [:dry_run] => [:environment] do |t, args| | ||
args.with_defaults(dry_run: false) | ||
|
||
if args.dry_run | ||
puts "Dry running reverse_geocode" | ||
else | ||
puts "Running reverse_geocode" | ||
end | ||
|
||
puts | ||
|
||
Restroom.all.each do |restroom| | ||
|
||
previous = restroom.full_address | ||
restroom.reverse_geocode | ||
|
||
if previous != restroom.full_address | ||
puts "ID: #{restroom.id}\t#{previous}\n" | ||
puts "\t\t\\==> #{restroom.full_address}\n\n" | ||
restroom.save unless args.dry_run | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does the trick for testing, but I don't like it. I think I'd rather fix the tests to truncate the db and simulate production better. We also need a test for the validation itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we be able to "simulate production better" by having real database data from production? I would be able to update
db/export.csv
with actual, recent data as it exists in production, if that would help.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DeeDeeG I think that would make sense. I'd like to also work on killing this conditional though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, also FYI. Changing the csv won't fix this issue. There's some sort of hook before the save that tries to geolocate these. I'm not sure what forces it to happen, but it is different than the uniqueness check.