Add Elastic reference class for vulnerability_reads index

Summary

  • Add a new Elastic reference class (Search::Elastic::References::Vulnerabilities::Read) for the vulnerability_reads index, following the same patterns as the existing Vulnerability reference class.
  • Add a BBM guard (BackfillOccurrenceIdToVulnerabilityReads) on preload_indexing_data to skip preloading until the backfill is complete.
  • Preload vulnerability_occurrence association in Vulnerabilities::Read.preload_indexing_data scope to avoid N+1 queries for created_at/updated_at.
  • Use VulnerabilityRead::EnhancedProxy instead of Vulnerability::EnhancedProxy for preloading.
  • Source created_at and updated_at from vulnerability_occurrence instead of vulnerability.
  • Use the reference class index method in the type class instead of duplicating index name logic.

Changed files

File Change
ee/lib/search/elastic/references/vulnerabilities/read.rb New reference class with DIRECT_FIELDS, PRELOADED_FIELDS, FIELDS_WITH_MIGRATIONS, SCHEMA_VERSIONS, set_field/waiting_on_migration? pattern, and backfill_occurrence_id_completed? guard
ee/spec/lib/search/elastic/references/vulnerabilities/read_spec.rb Specs for serialization, indexing JSON, preloading, BBM guard, N+1 queries, and field attributes
ee/app/models/vulnerabilities/read.rb Add :vulnerability_occurrence to preload_indexing_data scope
ee/lib/search/elastic/reference.rb Register new reference class
ee/lib/search/elastic/types/vulnerabilities/read.rb Use reference class index method
ee/spec/lib/search/elastic/reference_spec.rb Add specs for new reference class registration

Relates to

#592016 (closed)

Edited by Rushik Subba

Merge request reports

Loading