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

ENH Refactor the way selected options are returned for read only tag fields #310

Merged

Conversation

adunn49
Copy link
Contributor

@adunn49 adunn49 commented Oct 1, 2024

Description

When transforming a tag field to read only mode and calling the Field method on it for rendering, it was observed that all options in the tag field source were being returned from the database, and iterated to provide a full list on which the selected options are then filtered. Where there are large numbers of items in the source this was causing performance issues.

The getOptions method that is called for setting the values on the read only tag field accepts a $onlySelected parameter which, when set to true, will avoid the loading of all options, and instead just return the selected values. Calling the getOptions method in this way means that we no longer need the filtering within the ReadonlyTagField class.

Manual testing steps

These steps are included on issue #309

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@adunn49 adunn49 marked this pull request as ready for review October 1, 2024 21:42
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Very sensible change and good test coverage, thank you.

@GuySartorelli GuySartorelli merged commit 63cfb0d into silverstripe:3 Oct 7, 2024
11 checks passed
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