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

Update settings OBO uniqueness validations #443

Merged
merged 9 commits into from
Sep 9, 2024

Conversation

luciajanikova
Copy link
Member

@luciajanikova luciajanikova commented Jun 25, 2024

Tu sa ukazala potreba upravit trochu query kvoli tomu, ze mame rozne pripady, obo moze byt bud nil alebo aj prazdny string a podobne a potom to nezafungovalo. Bud teda takto upravme query alebo mozeme nejako skusit upratat, aby sme tie rozne tvary prazdneho obo odstranili.

@luciajanikova luciajanikova requested a review from jsuchal June 25, 2024 11:55
@@ -27,6 +27,6 @@ def destroy_with_box?

def validate_box(box)
box.errors.add(:settings_obo, :not_allowed) if obo.present?
box.errors.add(:settings_obo, :invalid) if boxes.where.not(id: box.id).where("settings ->> 'obo' = ?", box.settings_obo).exists?
box.errors.add(:settings_obo, :invalid) if boxes.where.not(id: box.id).map { |b| b.settings_obo.to_s }.include?(box.settings_obo.to_s)
Copy link
Member

Choose a reason for hiding this comment

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

Tu som skor za to, ze upravme tu logiku ze prazdny string nedovolime a bude tam vzdy nil lebo akonahle povolime prazdny string tak sa tato podmienka rozlezie aj vsade inde. Musime cistit data najskor ako sa len daju.

Copy link
Member

@jsuchal jsuchal left a comment

Choose a reason for hiding this comment

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

vid koment

@luciajanikova luciajanikova requested a review from jsuchal July 26, 2024 14:50
Copy link
Member

@jsuchal jsuchal left a comment

Choose a reason for hiding this comment

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

Neviem ci sme rails 7.1 ale toto mi pride ako dobry fix https://edgeapi.rubyonrails.org/classes/ActiveRecord/Normalization.html

@luciajanikova
Copy link
Member Author

Neviem ci sme rails 7.1 ale toto mi pride ako dobry fix https://edgeapi.rubyonrails.org/classes/ActiveRecord/Normalization.html

Sme 7.1, upravila som trochu @jsuchal

app/models/upvs/box.rb Outdated Show resolved Hide resolved
app/models/govbox/api_connection.rb Show resolved Hide resolved
app/models/upvs/box.rb Outdated Show resolved Hide resolved
class UpdateEmptyStringsBoxesSettingsObo < ActiveRecord::Migration[7.1]
def up
Upvs::Box.find_each do |box|
box.update(settings_obo: (box.settings_obo.present? ? box.settings_obo : nil))
Copy link
Member

Choose a reason for hiding this comment

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

Tu to vies asi urobit aj jednou query co si vypyta prazdny string ale good enough

@luciajanikova luciajanikova merged commit ceffc6b into main Sep 9, 2024
3 checks passed
@luciajanikova luciajanikova deleted the fix/settings_obo_uniqueness_validations branch September 9, 2024 08:06
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.

2 participants