saved queries guidance
Created by: slimsag
Changes to make:
- query-runner would pull list of saved searches from frontend on startup, but it was too expensive so AFTER doing that once on startup we would have the frontend notify the query-runner of updates (added, removed, changed saved searches) via
queryrunnerapi.Client.*
.- After this change, since we are storing saved searches in the DB directly and we don't have to parse all user/org settings from the DB -- it is cheap to get the full list (just
select * from
DB). So the query-runner should now just ask the frontend for the full list each time it loops (see query-runner/main.go).
- After this change, since we are storing saved searches in the DB directly and we don't have to parse all user/org settings from the DB -- it is cheap to get the full list (just
- When the query-runner sends out notifications for added/removed/changed queries (e.g. "you have been subscribed to recieve notifications about query " or "the query has been deleted from your organization"), this was previously handled by those endpoints in the query-runner that were called by the frontend via
queryrunnerapi.Client.*
. We cannot use those query-runner endpoints now because we removed them (see #1 (closed) above) (which is simpler), but due to this we need to re-implement this notification logic by simply diffing the last list we got from the frontend AND the new list we got to determine which saved searches were added/removed/modified. Implement this logic here: https://github.com/sourcegraph/sourcegraph/commit/715173a6def8da843e6160efcd10afe3a20bc91d#diff-2d6316986810e5853865d0366967952bR161 - When the query-runner used to recieve the full list of saved searches, it was essentially a mirror of what was in the user settings. You will need to update this endpoint to pull information from the DB instead of pulling all user+org configurations from the DB and getting info from there. See how to implement this in https://github.com/sourcegraph/sourcegraph/commit/0336be151c79e7a20d56c273c078ef38fa1eca1d and https://github.com/sourcegraph/sourcegraph/commit/b9e06da77923e74d91ef7ecff0bd6a9383dd60cc
- Finally, there is unused code we can remove see https://github.com/sourcegraph/sourcegraph/commit/99f4e31e35f8efbeecc81ee5e83292f7a50467e6 for that.
If you get this PR to compile + be based on your DB changes, everything should work :)