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

add multi-field scoping for slugs #274

Merged
merged 9 commits into from
Apr 21, 2024

Conversation

mikekosulin
Copy link
Contributor

  • Add option for multi-field scoping in slugs, expanding beyond single-field/relation scopes without altering existing functionality

Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Looks great! Let's simplify the code a bit with a uniform Array(...).each ...

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
lib/mongoid/slug.rb Outdated Show resolved Hide resolved
lib/mongoid/slug.rb Outdated Show resolved Hide resolved
lib/mongoid/slug/unique_slug.rb Outdated Show resolved Hide resolved
@mikekosulin mikekosulin marked this pull request as draft October 22, 2023 15:55
@mikekosulin mikekosulin marked this pull request as ready for review October 22, 2023 18:10
Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Much better, but the implementation is still a little confusing. See below. Thanks for hanging in here with me!

CHANGELOG.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lib/mongoid/slug.rb Outdated Show resolved Hide resolved
lib/mongoid/slug/unique_slug.rb Outdated Show resolved Hide resolved
Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I think version.rb is the last thing.

LMK if the nit makes sense, otherwise I can merge.

lib/mongoid/slug.rb Outdated Show resolved Hide resolved
@dblock
Copy link
Collaborator

dblock commented Oct 23, 2023

@johnnyshields any comments/issues?

Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks. I'll wait for @johnnyshields to chime in, will merge this week if we don't hear from him.

@mikekosulin
Copy link
Contributor Author

Hey @dblock, @johnnyshields any updates on merging? 😊

README.md Outdated
end
```

Note: this approach creates multiple indexes, differing from single-field scoping, and impacting database performance and storage.
Copy link
Member

@johnnyshields johnnyshields Jan 12, 2024

Choose a reason for hiding this comment

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

Hmmm... shouldn't this still create only one compound index? For example:

slug :name, scope: %i[company_id department_id]

# Should create
index company_id: 1, department_id: 1, _slugs: 1

# NOT
index company_id: 1, _slugs: 1
index department_id: 1, _slugs: 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the late response. You're right, it creates only a compound index in this case. I've fixed it here and forgot to remove the note.

@johnnyshields
Copy link
Member

@mikekosulin see comment

@johnnyshields johnnyshields merged commit c52831e into mongoid:master Apr 21, 2024
14 of 16 checks passed
@johnnyshields
Copy link
Member

@mikekosulin great work, merged! Thanks.

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