Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: turn off slow query when sync failed (#5612)
Liu Ji24edb9dce5c1
diff --git a/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue b/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vueindex bb2060e6f4..fc9b77ed59 100644--- a/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue+++ b/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue@@ -112,29 +112,43 @@ const changeEnvironment = (id: EnvironmentId | undefined) => {state.filter.environment = environmentList.value.find((env) => env.id === id);};+const patchInstanceSlowQueryPolicy = (instance: Instance, active: boolean) => {+ const payload: SlowQueryPolicyPayload = {+ active,+ };+ return policyStore.upsertPolicyByResourceTypeAndPolicyType(+ "instance",+ instance.id,+ "bb.policy.slow-query",+ {+ payload,+ }+ );+};+const toggleActive = async (instance: Instance, active: boolean) => {try {- const payload: SlowQueryPolicyPayload = {- active,- };- await policyStore.upsertPolicyByResourceTypeAndPolicyType(- "instance",- instance.id,- "bb.policy.slow-query",- {- payload,- }- );+ await patchInstanceSlowQueryPolicy(instance, active);if (active) {// When turning ON an instance's slow query, call the corresponding// API endpoint to sync slow queries from the instance immediately.- await slowQueryStore.syncSlowQueriesByInstance(instance);+ try {+ await slowQueryStore.syncSlowQueriesByInstance(instance);+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+ } catch (err: any) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: typeof err.message === "string" ? err.message : String(err),+ });++ await patchInstanceSlowQueryPolicy(instance, false);+ }}- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.updated"),- });} catch {// nothing}