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

DEV-1124: holdings are equal if fields are equal or both empty #299

Merged
merged 2 commits into from
May 8, 2024

Conversation

aelkiss
Copy link
Member

@aelkiss aelkiss commented May 3, 2024

This should address the underlying issue we were seeing with duplicate holdings not being cleaned up.

It probably would not hurt to add a test case that exercises the specific issue we were seeing -- create a cluster with a holding with some nil fields, update it with a holding with corresponding empty-string fields; ensure that they match and it doesn't end up with duplicate holdings. I will work on that next week, but wanted to get something up for a look now.

@aelkiss aelkiss requested a review from mwarin May 3, 2024 21:02
end

(described_class.fields.keys - ["date_received", "uuid", "_id"]).each do |attr|
it "== is false if #{attr} doesn't match" do
h2[attr] = nil
expect(h == h2).to be(false)
# ensure attribute in h2 is different from h but
Copy link
Member Author

Choose a reason for hiding this comment

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

Before, we were always setting h2[attr] to nil, so the behavior change made this test fail -- now it sets it to an appropriate non-nil but non-equal type.

Copy link
Contributor

@mwarin mwarin left a comment

Choose a reason for hiding this comment

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

Makes sense. Just fix the standardrb warnings.
APPROVE.

Copy link
Contributor

@mwarin mwarin left a comment

Choose a reason for hiding this comment

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

Gah, I meant to actually approve not just say "APPROVE".
APPROVE.

… blank

The holdings matching function used update_key (a modified hash value)
rather than equality; this update folds empty string & nil for computing
that update_key as well.
@aelkiss aelkiss requested a review from mwarin May 6, 2024 16:26
@aelkiss
Copy link
Member Author

aelkiss commented May 6, 2024

@mwarin I added a test to cover the actual update situation, which revealed that for performance we were using update_key (a modified hash value) rather than equality checking in the holdings update. Please take a look and make sure this all still makes sense!

@coveralls
Copy link

coveralls commented May 6, 2024

Coverage Status

coverage: 95.018% (+0.006%) from 95.012%
when pulling cc206fa on DEV-1124
into ed3107a on main.

Copy link
Contributor

@mwarin mwarin left a comment

Choose a reason for hiding this comment

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

Ran tests (green), looked at code (makes sense), saw new test (good).
APPROVE.

@aelkiss aelkiss merged commit 013f4f8 into main May 8, 2024
1 check passed
@aelkiss aelkiss deleted the DEV-1124 branch May 8, 2024 12:42
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.

3 participants