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

Closes #10560: New global search #10676

Merged
merged 38 commits into from
Oct 21, 2022
Merged

Closes #10560: New global search #10676

merged 38 commits into from
Oct 21, 2022

Conversation

jeremystretch
Copy link
Member

Closes: #10560

  • Introduce CachedValue model to store cached model field values for search
  • Introduce an indexer class for all searchable models, specifying fields and their weights ($app/search.py)
  • Introduce the reindex management command to [re]build the cache
  • Implement table-based search results with HTMX
  • Add search_weight field to CustomField model
  • Remove legacy search backend
  • Remove object type selector from UI search bar
  • Replace search_options template tag with inclusion template (inc/searchbar.html)
  • Introduce RestrictedGenericForeignKey and RestrictedPrefetch to enable restricting pre-fetched GFK objects based on user permissions

@kkthxbye-code
Copy link
Contributor

The following instances of bulk_create and bulk_update should probably be changed to normal saving, otherwise signals are not sent.

ConsolePort.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.consoleporttemplates.all()]
)
ConsoleServerPort.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.consoleserverporttemplates.all()]
)
PowerPort.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.powerporttemplates.all()]
)
PowerOutlet.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.poweroutlettemplates.all()]
)
Interface.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.interfacetemplates.all()]
)
RearPort.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.rearporttemplates.all()]
)
FrontPort.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.frontporttemplates.all()]
)
ModuleBay.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.modulebaytemplates.all()]
)
DeviceBay.objects.bulk_create(
[x.instantiate(device=self) for x in self.device_type.devicebaytemplates.all()]
)

component_model.objects.bulk_create(create_instances)
component_model.objects.bulk_update(update_instances, ['module'])

This should probably have been done anyway, as changelogs are not created currently for these objects. It will make those operations significally slower though, not sure if there's a fast way to bulk create and fire off signals in django, I'm guessing you would have to override bulk_create and bulk_update to send the signals manually after successful insert/update.

@jeremystretch
Copy link
Member Author

@kkthxbye-code that's a very good observation. We've had a de facto ban on bulk_create() and bulk_update() outside of tests and migrations for a long time for precisely this reason. I think their use for replicating device components has been ignored until now because the absence of change logs for these actions hasn't been impactful, but you're correct that this needs to change. I've opened housekeeping issue #10694 to capture this.

@jeremystretch jeremystretch marked this pull request as ready for review October 20, 2022 16:59
@jeremystretch
Copy link
Member Author

Need to figure out why we have a test failing under Python 3.9+.

@jeremystretch jeremystretch added the beta Concerns a bug/feature in a beta release label Oct 20, 2022
@jeremystretch jeremystretch merged commit 9628dea into feature Oct 21, 2022
@jeremystretch jeremystretch deleted the 10560-search branch October 21, 2022 17:16
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants