fix(server): clean up unnecessary refreshes
This commit is contained in:
@@ -79,7 +79,6 @@ impl SearchRuntime {
|
|||||||
}
|
}
|
||||||
generation::activate(&self.pool, &active).await?;
|
generation::activate(&self.pool, &active).await?;
|
||||||
*self.generation.write().await = Some(active);
|
*self.generation.write().await = Some(active);
|
||||||
self.refresh_all_permission_cursors().await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +321,7 @@ impl SearchRuntime {
|
|||||||
.await
|
.await
|
||||||
.map_err(|error| RuntimeError::database("load search permission cursor", error))?
|
.map_err(|error| RuntimeError::database("load search permission cursor", error))?
|
||||||
};
|
};
|
||||||
let applied = applied.unwrap_or(-1);
|
let applied = applied.unwrap_or_default();
|
||||||
if applied >= revision {
|
if applied >= revision {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -330,13 +329,11 @@ impl SearchRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn refresh_permission_cursor(&self, workspace_id: &str) -> RuntimeResult<()> {
|
async fn refresh_permission_cursor(&self, workspace_id: &str) -> RuntimeResult<()> {
|
||||||
let revision: i64 = sqlx::query_scalar(
|
let revision: i64 = sqlx::query_scalar("SELECT revision FROM workspace_permission_revisions WHERE workspace_id=$1")
|
||||||
"SELECT coalesce(max(revision),0)::bigint FROM workspace_permission_changes WHERE workspace_id=$1",
|
.bind(workspace_id)
|
||||||
)
|
.fetch_one(&self.pool)
|
||||||
.bind(workspace_id)
|
.await
|
||||||
.fetch_one(&self.pool)
|
.map_err(|error| RuntimeError::database("load search permission revision", error))?;
|
||||||
.await
|
|
||||||
.map_err(|error| RuntimeError::database("load search permission revision", error))?;
|
|
||||||
let generation = self.active_generation().await?;
|
let generation = self.active_generation().await?;
|
||||||
if self.remote.is_none() {
|
if self.remote.is_none() {
|
||||||
let mut cursors = self.embedded_permission_cursors.write().await;
|
let mut cursors = self.embedded_permission_cursors.write().await;
|
||||||
@@ -358,17 +355,6 @@ impl SearchRuntime {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn refresh_all_permission_cursors(&self) -> RuntimeResult<()> {
|
|
||||||
let workspace_ids: Vec<String> = sqlx::query_scalar("SELECT id FROM workspaces")
|
|
||||||
.fetch_all(&self.pool)
|
|
||||||
.await
|
|
||||||
.map_err(|error| RuntimeError::database("load search permission workspaces", error))?;
|
|
||||||
for workspace_id in workspace_ids {
|
|
||||||
self.refresh_permission_cursor(&workspace_id).await?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(in crate::runtime::backend_runtime) async fn reconcile_workspace(
|
pub(in crate::runtime::backend_runtime) async fn reconcile_workspace(
|
||||||
&self,
|
&self,
|
||||||
capability: SystemSearchCapability,
|
capability: SystemSearchCapability,
|
||||||
|
|||||||
Reference in New Issue
Block a user