Skip to content

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

chore: clear database change history cache (#13659)

ecmadao786d8a33c064
diff --git a/frontend/src/components/IssueV1/logic/poll.ts b/frontend/src/components/IssueV1/logic/poll.ts
index 3401a6d3c0..92610068a3 100644
--- a/frontend/src/components/IssueV1/logic/poll.ts
+++ b/frontend/src/components/IssueV1/logic/poll.ts
@@ -1,13 +1,26 @@
import { computed, watch } from "vue";
+import { databaseForTask } from "@/components/IssueV1/logic";
import { useProgressivePoll } from "@/composables/useProgressivePoll";
-import { experimentalFetchIssueByUID } from "@/store";
+import { experimentalFetchIssueByUID, useChangeHistoryStore } from "@/store";
+import type { ComposedIssue } from "@/types";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
import {
extractIssueUID,
extractProjectResourceName,
isValidTaskName,
} from "@/utils";
+import { flattenTaskV1List } from "@/utils";
import { useIssueContext } from "./context";
+const clearChangeHistory = (issue: ComposedIssue) => {
+ const changeHistoryStore = useChangeHistoryStore();
+ const tasks = flattenTaskV1List(issue.rolloutEntity);
+ for (const task of tasks) {
+ const database = databaseForTask(issue, task);
+ changeHistoryStore.clearCache(database.name);
+ }
+};
+
export const usePollIssue = () => {
const { isCreating, ready, issue, events, activeTask } = useIssueContext();
@@ -17,11 +30,19 @@ export const usePollIssue = () => {
const refreshIssue = () => {
if (!shouldPollIssue.value) return;
-
experimentalFetchIssueByUID(
extractIssueUID(issue.value.name),
extractProjectResourceName(issue.value.project)
- ).then((updatedIssue) => (issue.value = updatedIssue));
+ ).then((updatedIssue) => {
+ if (
+ issue.value.status !== IssueStatus.DONE &&
+ updatedIssue.status === IssueStatus.DONE
+ ) {
+ clearChangeHistory(updatedIssue);
+ }
+
+ issue.value = updatedIssue;
+ });
};
const poller = useProgressivePoll(refreshIssue, {
diff --git a/frontend/src/store/modules/v1/changeHistory.ts b/frontend/src/store/modules/v1/changeHistory.ts
index c91f5a4f93..05909a8552 100644
--- a/frontend/src/store/modules/v1/changeHistory.ts
+++ b/frontend/src/store/modules/v1/changeHistory.ts
@@ -39,6 +39,10 @@ export const useChangeHistoryStore = defineStore("changeHistory_v1", () => {
});
};
+ const clearCache = (parent: string) => {
+ changeHistoryListMapByDatabase.delete(parent);
+ };
+
const fetchChangeHistoryList = async (
params: Partial<ListChangeHistoriesRequest>
) => {
@@ -154,6 +158,7 @@ export const useChangeHistoryStore = defineStore("changeHistory_v1", () => {
};
return {
+ clearCache,
fetchChangeHistoryList,
getOrFetchChangeHistoryListOfDatabase,
changeHistoryListByDatabase,