Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: update find anomaly list api (#2789)

boojackdaba9dac8135
diff --git a/frontend/src/store/modules/anomaly.ts b/frontend/src/store/modules/anomaly.ts
index 40e93843a4..c824d8e92d 100644
--- a/frontend/src/store/modules/anomaly.ts
+++ b/frontend/src/store/modules/anomaly.ts
@@ -88,6 +88,12 @@ const buildQueryByAnomalyFind = (find: AnomalyFind): string => {
if (find.databaseId && find.databaseId !== UNKNOWN_ID) {
query.database = find.databaseId;
}
+ if (find.rowStatus) {
+ query.rowStatus = find.rowStatus;
+ }
+ if (find.type) {
+ query.type = find.type;
+ }
return QueryString.stringify(query);
};
diff --git a/frontend/src/types/anomaly.ts b/frontend/src/types/anomaly.ts
index 9252e3588f..2b6b9e6c59 100644
--- a/frontend/src/types/anomaly.ts
+++ b/frontend/src/types/anomaly.ts
@@ -7,6 +7,7 @@ import {
Instance,
InstanceId,
Principal,
+ RowStatus,
} from ".";
export type AnomalyType =
@@ -73,8 +74,6 @@ export type Anomaly = {
export type AnomalyFind = {
instanceId?: InstanceId;
databaseId?: DatabaseId;
-
- // Not supported by server-side yet.
- // rowStatus?: RowStatus;
- // type?: AnomalyType;
+ rowStatus?: RowStatus;
+ type?: AnomalyType;
};
diff --git a/server/anomaly.go b/server/anomaly.go
index 7803f13841..a81bb18211 100644
--- a/server/anomaly.go
+++ b/server/anomaly.go
@@ -14,9 +14,9 @@ import (
func (s *Server) registerAnomalyRoutes(g *echo.Group) {
g.GET("/anomaly", func(c echo.Context) error {
ctx := c.Request().Context()
- rowStatus := api.Normal
+ normalRowStatus := api.Normal
anomalyFind := &api.AnomalyFind{
- RowStatus: &rowStatus,
+ RowStatus: &normalRowStatus,
}
if instanceIDStr := c.QueryParam("instance"); instanceIDStr != "" {
instanceID, err := strconv.Atoi(instanceIDStr)
@@ -33,6 +33,13 @@ func (s *Server) registerAnomalyRoutes(g *echo.Group) {
}
anomalyFind.DatabaseID = &databaseID
}
+ if rowStatus := c.QueryParam("rowStatus"); rowStatus != "" {
+ anomalyFind.RowStatus = (*api.RowStatus)(&rowStatus)
+ }
+ if anomalyType := c.QueryParam("type"); anomalyType != "" {
+ anomalyFind.Type = (*api.AnomalyType)(&anomalyType)
+ }
+
anomalyList, err := s.store.FindAnomaly(ctx, anomalyFind)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch anomaly list").SetInternal(err)