fix: mark search index ready at service creation, not just during build
The search index ready flag is an in-memory bool that resets to false on every app restart. It was only set to true inside build(), which runs in a goroutine after SoftScanAllLibraries completes. If the user searched before the build goroutine started, IsReady() returned false and the search took the slow path (LB popularity + cross-ref: ~2.3s) even though the SQLite index had all the data from the previous build. Now MarkReadyIfPopulated() is called eagerly in NewExploreService — the index is queryable as soon as the service is constructed, before any goroutines launch. If the explore_index table has rows, ready=true immediately.
This commit is contained in:
@@ -48,6 +48,7 @@ func NewExploreService(logger *slog.Logger, db *database.DB) *Service {
|
||||
db, cache, mbBackgroundLimiter, logger.WithGroup("artist-image"),
|
||||
)
|
||||
index := NewSearchIndex(db, lb, artistImg, logger.WithGroup("search-index"))
|
||||
index.MarkReadyIfPopulated() // make index queryable immediately if data exists
|
||||
libMBID := NewLibraryMBIDIndex(db)
|
||||
|
||||
logger.Info("explore service created")
|
||||
|
||||
Reference in New Issue
Block a user