Skip to content
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

Independent cities #3603

Merged
merged 8 commits into from
May 30, 2023
Merged

Independent cities #3603

merged 8 commits into from
May 30, 2023

Conversation

cielf
Copy link
Collaborator

@cielf cielf commented May 18, 2023

Resolves #3584

Description

The initial counties implementation didn't include the independent cities of Baltimore, St. Louis, Carson City, and a slew in Virginia. This addresses that.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

manual verification that Baltimore is in the county lists
On copy of production, checked one partner that has served areas. Same before and after.

@cielf cielf requested a review from dorner May 18, 2023 19:54
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cielf a question/suggestion/worry.

"Other US County, other US region", other US region
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this probably shouldn't be a County in the database. We should have separate logic to ensure this always comes last. Otherwise it'll be in a weird middle-of-the-list. Technically we can just move this line to the end of this CSV, but my hunch is there'll be some ordering tomfoolery which will make it not always come last.

Copy link
Collaborator Author

@cielf cielf May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I see what you're saying -- though with a list this long most (I'm not going to be putting a number on it) people are going to be accessing their counties by typing ahead, so I'm not sure it's that big an issue.

Honestly, I had not noticed that I wasn't ordering alpha before displaying the list -- probably because the original list was in strict alpha. I'm going to fix that.

I also thought about whether we could just remove "Other US county" if we have total US coverage. But we might have a case where someone has 2% spread over several counties, and would want to just use it for that.

Copy link
Collaborator Author

@cielf cielf May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And moving it to the end wouldn't work -- it's already in the db, after all, so if it's ordered by creation, it would be weirdly at the end of the counties but before the cities, and if it's alpha, it will be in the middle.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add an additional ordering priority, set everything else to something low, and Other to 9999, and then order by alpha within the ordering value . I think it's a mite kludgey, but if keeping Other at the end is important, that might be the easiest way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorner -- What do you think of that? It would also have the advantage of allowing us to put all the US counties first if we wanted to if/when we add other countries (and we do have a Toronto bank that has signed up)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that makes a lot of sense... maybe add a type/metadata/category etc. column which we can use to group results. Then you can do a sort by category + name. And if Other has its own category then we can ensure it shows up the right way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Allows the same results-ish but with more sophistication. Assuming support doesn't blow up I'll try to get that in tomorrow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also noticed I had a leading space on the regions. Fixed that.

@cielf cielf requested a review from dorner May 23, 2023 20:40
@@ -0,0 +1,5 @@
class AddCategoryToCounties < ActiveRecord::Migration[7.0]
def change
add_column :counties, :category, :string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really an enum rather than a string - can we do it this way? https://blog.saeloun.com/2022/01/12/rails-7-adds-custom-enum-support-in-postgresql/#after

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we can.

lib/tasks/load_us_counties.rake Outdated Show resolved Hide resolved
cielf and others added 2 commits May 28, 2023 17:29
Co-authored-by: Daniel Orner <daniel.orner@flipp.com>
@cielf cielf requested a review from dorner May 28, 2023 22:17
counties<< {name: row[0], region: row[1]}
CSV.foreach("lib//assets//us_county_and_equivalent_list.csv") do |row|
category = row[2] ? row[2].strip.presence : "US_County"
counties << { name: row[0], region: row[1].strip, category: category }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing is off here? :) Otherwise looks good!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That darn rubocop -- just when you start relying on it!

@cielf cielf requested a review from dorner May 30, 2023 15:46
@dorner
Copy link
Collaborator

dorner commented May 30, 2023

Done and done!

@dorner dorner merged commit 9fd8a77 into rubyforgood:main May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Independent Cities to counties list
2 participants