Skip to content

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

Clean up activity model

天舟d1d0bf4de9e8
diff --git a/frontend/src/miragejs/factories/activity.js b/frontend/src/miragejs/factories/activity.js
index a06f57b674..ad2a335db7 100644
--- a/frontend/src/miragejs/factories/activity.js
+++ b/frontend/src/miragejs/factories/activity.js
@@ -1,10 +1,17 @@
import { Factory } from "miragejs";
+import { UNKNOWN_ID } from "../../types";
export default {
activity: Factory.extend({
+ creatorId() {
+ return UNKNOWN_ID;
+ },
createdTs(i) {
return Date.now() - (10 - i) * 1800 * 1000;
},
+ updaterId() {
+ return UNKNOWN_ID;
+ },
lastUpdatedTs(i) {
return Date.now() - (10 - i) * 1800 * 1000;
},
@@ -14,9 +21,6 @@ export default {
containerId() {
return "0";
},
- creatorId() {
- return "100";
- },
comment() {
return "";
},
diff --git a/frontend/src/miragejs/models/index.js b/frontend/src/miragejs/models/index.js
index 3bec6dd8f2..b09bd42902 100644
--- a/frontend/src/miragejs/models/index.js
+++ b/frontend/src/miragejs/models/index.js
@@ -56,6 +56,8 @@ export default {
workspace: belongsTo(),
}),
+ activityNew: Model,
+
activityPatch: Model,
message: Model.extend({
diff --git a/frontend/src/miragejs/routes/activity.js b/frontend/src/miragejs/routes/activity.js
index 67b78ad8e5..974d5aac00 100644
--- a/frontend/src/miragejs/routes/activity.js
+++ b/frontend/src/miragejs/routes/activity.js
@@ -29,6 +29,7 @@ export default function configureActivity(route) {
const newActivity = {
...attrs,
createdTs: ts,
+ updaterId: attrs.creatorId,
lastUpdatedTs: ts,
actionType: "bytebase.task.comment.create",
workspaceId: WORKSPACE_ID,
diff --git a/frontend/src/miragejs/routes/task.js b/frontend/src/miragejs/routes/task.js
index 148bc660ef..551737afbc 100644
--- a/frontend/src/miragejs/routes/task.js
+++ b/frontend/src/miragejs/routes/task.js
@@ -58,11 +58,12 @@ export default function configureTask(route) {
const createdTask = schema.tasks.create(newTask);
schema.activities.create({
+ creatorId: attrs.creatorId,
createdTs: ts,
+ updaterId: attrs.updaterId,
lastUpdatedTs: ts,
actionType: "bytebase.task.create",
containerId: createdTask.id,
- creatorId: attrs.creatorId,
comment: "",
workspaceId: WORKSPACE_ID,
});
@@ -268,11 +269,12 @@ export default function configureTask(route) {
};
schema.activities.create({
+ creatorId: attrs.updaterId,
createdTs: ts,
+ updaterId: attrs.updaterId,
lastUpdatedTs: ts,
actionType: "bytebase.task.field.update",
containerId: updatedTask.id,
- creatorId: attrs.updaterId,
comment: attrs.comment,
payload,
workspaceId: WORKSPACE_ID,
diff --git a/frontend/src/miragejs/seeds/index.ts b/frontend/src/miragejs/seeds/index.ts
index 01b7b571e1..ed44508be8 100644
--- a/frontend/src/miragejs/seeds/index.ts
+++ b/frontend/src/miragejs/seeds/index.ts
@@ -196,10 +196,8 @@ const workspacesSeeder = (server: any) => {
const createdActivity = server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
- creator: {
- id: ws1Dev1.id,
- name: ws1Dev1.name,
- },
+ creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
workspace: workspace1,
});
@@ -331,10 +329,8 @@ const workspacesSeeder = (server: any) => {
server.create("activity", {
actionType: "bytebase.task.comment.create",
containerId: task.id,
- creator: {
- id: user.id,
- name: user.name,
- },
+ creatorId: user.id,
+ updaterId: user.id,
comment: faker.fake("{{lorem.paragraph}}"),
workspace: workspace1,
});
@@ -377,10 +373,8 @@ const workspacesSeeder = (server: any) => {
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
- creator: {
- id: ws1Dev1.id,
- name: ws1Dev1.name,
- },
+ creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
workspace: workspace1,
});
@@ -390,6 +384,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.comment.create",
containerId: task.id,
creatorId: user.id,
+ updaterId: user.id,
comment: faker.fake("{{lorem.paragraph}}"),
workspace: workspace1,
});
@@ -459,6 +454,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.create",
containerId: task.id,
creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
workspace: workspace1,
});
@@ -468,6 +464,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.comment.create",
containerId: task.id,
creatorId: user.id,
+ updaterId: user.id,
comment: faker.fake("{{lorem.paragraph}}"),
workspace: workspace1,
});
@@ -492,10 +489,8 @@ const workspacesSeeder = (server: any) => {
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
- creator: {
- id: ws1Owner.id,
- name: ws1Owner.name,
- },
+ creatorId: ws1Owner.id,
+ updaterId: ws1Owner.id,
workspace: workspace1,
});
@@ -505,6 +500,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.comment.create",
containerId: task.id,
creatorId: user.id,
+ updaterId: user.id,
comment: faker.fake("{{lorem.paragraph}}"),
workspace: workspace1,
});
@@ -530,6 +526,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.create",
containerId: task.id,
creatorId: ws1Dev2.id,
+ updaterId: ws1Dev2.id,
workspace: workspace1,
});
@@ -539,6 +536,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.comment.create",
containerId: task.id,
creatorId: user.id,
+ updaterId: user.id,
comment: faker.fake("{{lorem.paragraph}}"),
workspace: workspace1,
});
@@ -562,6 +560,7 @@ const workspacesSeeder = (server: any) => {
actionType: "bytebase.task.create",
containerId: task.id,
creatorId: ws2Dev.id,
+ updaterId: ws2Dev.id,
workspace: workspace2,
});
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index d25a4318c1..4788494029 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -13,10 +13,14 @@ function convert(activity: ResourceObject, rootGetters: any): Activity {
const creator = rootGetters["principal/principalById"](
activity.attributes.creatorId
);
+ const updater = rootGetters["principal/principalById"](
+ activity.attributes.updaterId
+ );
return {
- ...(activity.attributes as Omit<Activity, "id" | "creator">),
+ ...(activity.attributes as Omit<Activity, "id" | "creator" | "updater">),
id: activity.id,
creator,
+ updater,
};
}
@@ -69,7 +73,7 @@ const actions = {
(
await axios.post(`/api/activity`, {
data: {
- type: "activity",
+ type: "activitynew",
attributes: newActivity,
},
})
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index c5b1c61ce3..58b71b22ef 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -166,6 +166,7 @@ export const unknown = (
lastUpdatedTs: 0,
actionType: "bytebase.task.create",
creator: UNKNOWN_PRINCIPAL,
+ updater: UNKNOWN_PRINCIPAL,
comment: "<<Unknown comment>>",
};
@@ -617,13 +618,14 @@ export type ActionPayloadType = ActionTaskFieldUpdatePayload;
export type Activity = {
id: ActivityId;
+ creator: Principal;
+ createdTs: number;
+ updater: Principal;
+ lastUpdatedTs: number;
// The object where this activity belongs
// e.g if actionType is "bytebase.task.xxx", then this field refers to the corresponding task's id.
containerId: ContainerId;
- createdTs: number;
- lastUpdatedTs: number;
actionType: ActionType;
- creator: Principal;
comment: string;
payload?: ActionPayloadType;
};