Skip to content

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

fix: filtering by rowstatus correctly (#733)

Liu Ji05487c77adff
diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.ts
index 30eb7ebc42..018c9773ba 100644
--- a/frontend/src/store/modules/project.ts
+++ b/frontend/src/store/modules/project.ts
@@ -179,19 +179,35 @@ const actions = {
{ commit, rootGetters }: any,
{
userId,
- rowStatusList,
+ rowStatusList = [],
}: {
userId: PrincipalId;
rowStatusList?: RowStatus[];
}
) {
- const path =
- `/api/project?user=${userId}` +
- (rowStatusList ? "&rowstatus=" + rowStatusList.join(",") : "");
- const data = (await axios.get(`${path}`)).data;
- const projectList = data.data.map((project: ResourceObject) => {
- return convert(project, data.included, rootGetters);
- });
+ const projectList: Project[] = [];
+
+ const fetchProjectList = async (rowStatus?: RowStatus) => {
+ let path = `/api/project?user=${userId}`;
+ if (rowStatus) path += `&rowstatus=${rowStatus}`;
+ const data = (await axios.get(path)).data;
+ const list: Project[] = data.data.map((project: ResourceObject) => {
+ return convert(project, data.included, rootGetters);
+ });
+ // projects are mutual excluded by different rowstatus
+ // so we don't need to unique them by id here
+ projectList.push(...list);
+ };
+
+ if (rowStatusList.length === 0) {
+ // if no rowStatus specified, fetch all
+ await fetchProjectList();
+ } else {
+ // otherwise, fetch different rowStatus one-by-one
+ for (const rowStatus of rowStatusList) {
+ await fetchProjectList(rowStatus);
+ }
+ }
commit("upsertProjectList", projectList);
return projectList;