Zoekt project search should select correct zoekt node for replica search

What does this MR do and why?

With the introduction of replicas the project should have has_many relations with the zoekt_repositories. Override the zoekt_nodes method to select the node that has a ready repository for the project search.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

SELECT
    "zoekt_nodes".*
FROM
    "zoekt_nodes"
    INNER JOIN "zoekt_indices" ON "zoekt_indices"."zoekt_node_id" = "zoekt_nodes"."id"
    INNER JOIN "zoekt_repositories" ON "zoekt_repositories"."zoekt_index_id" = "zoekt_indices"."id"
WHERE
    "zoekt_nodes"."last_seen_at" >= '2024-10-04 18:47:37.413989'
    AND "zoekt_repositories"."state" = 10
    AND "zoekt_repositories"."project_id" = 278964

https://console.postgres.ai/shared/a26df723-8f75-49dd-9b02-8efa3e8264c7

Related to #494418 (closed)

Edited by Ravi Kumar

Merge request reports

Loading