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

Prevent conflicting tags being added in new Validate #3652

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

misaugstad
Copy link
Member

Fixes #3635

Fixes a bug where conflicting tags (like "no alternate route" and "alternate route present") could both be added to a label through the new Validate page. Some more specifics:

  • I added a new mutually_exclusive_with column to thetag table, so that these mutual exclusivity relationships are recorded in the db. This helps us deal with the more programmatically, and I'm hoping that it makes it easier to remember to address them when this comes up again.
  • I'm using this new column to check for mutual exclusivity before inserting/updating on the label or label_history table. If we fail to prevent this issue on the front-end, we'll now log a warning on the back-end and remove both of the mutually exclusive tags before inserting/updating. This way we'll never have conflicting tags in the db, even if we mess up on the front-end.
  • Added the front-end fix for the new Validate page so that it works like it does in Explore (choosing 'no alternate route' will now automatically remove 'alternate route present' if it was selected).
  • I ran a query on our live databases, and no one has tried to add conflicting tags using the tool, so we don't need to fix any live data. Here's the query I used to check for this:
    SELECT COUNT(*)
    FROM label
    WHERE ('alternate route present' = ANY(tags) AND 'no alternate route' = ANY(tags))
        OR ('missing tactile warning' = ANY(tags) AND 'tactile warning' = ANY(tags))
        OR ('street has a sidewalk' = ANY(tags) AND 'street has no sidewalks' = ANY(tags))
        OR ('one button' = ANY(tags) AND 'two buttons' = ANY(tags))
    
  • I also added a UNIQUE(label_type_id, tag) constraint to the tag table. This wasn't an issue, but it's technically a constraint we had, so figured it was worth updating the db since I was already fixing up this table. Doesn't impact anything right now.
Things to check before submitting the PR
  • I've written a descriptive PR title.
  • I've added/updated comments for large or confusing blocks of code.
  • I've updated any logging. Clicks, keyboard presses, and other user interactions should be logged. If you're not sure how (or if you need to update the logging), ask Mikey. Then make sure the documentation on this wiki page is up to date for the logs you added/updated.

@misaugstad misaugstad self-assigned this Sep 12, 2024
@misaugstad
Copy link
Member Author

Oh! And I chose not to refactor our Explore page code that deals with mutually exclusive tags to use this newer functionality, since we're planning on redoing the context menu anyway. What we have is working now, so not worth the effort to do a refactor now.

@misaugstad misaugstad merged commit 236d8b8 into develop Sep 12, 2024
@misaugstad misaugstad deleted the 3635-prevent-conflicting-tags-new-validate branch September 12, 2024 23:53
@misaugstad misaugstad mentioned this pull request Sep 13, 2024
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.

Prevent the addition of conflicting tags in New Validate Beta
1 participant