Skip to content

insights: enable streaming for backend search insights

Warren Gifford requested to merge insights/enable-stream-backend-search into main

Created by: leonore

closes #34989 (closed)

There's a bit of refactoring going on in this PR so I'll highlight the changes:

  • Moved some bits around (checkSubRepoPermissions, insightsHandler). No changes there
  • similar to the computeHandler, we now have a searchHandler that branches off into either generateSearchRecordings or generateSearchStreamRecordings according to the new site admin setting, insights.search.graphql.
  • the only difference between the computeHandler and the searchHandler is that we pass in series information to the search sub-functions because we need the info for dirty queries (which are only handled in the standard search path)
    • because of this there could be worth in commonising these 2 but for now the copy pasta seems pretty clear, possibly clearer than a lot of if/else
  • added search functions on the workHandler similar to what was done for the compute functions so that this could be unit tested.

It might be a bit easier to read the diff for the work_handler as the full file rather than looking at the additions/deletions as some things were moved around for clarity.

Test plan

Created insights and observed they were getting created correctly. Observed Streaming Counts, streaming: [x] logs

Added unit tests for generating search stream recordings. Adding them for the regular search path would be a bit more complicated due to the complexity of the gqlSearchResponse. If we decide it's worth it we should probably refactor the general function so that object is converted into something a bit more readable.

Ran migration and observed search-stream records were updated correctly.

Merge request reports

Loading