Skip to content

Commit ed7a8bc

Browse files
committed
stop tracking state_event in mysql
1 parent e19885d commit ed7a8bc

File tree

3 files changed

+2
-71
lines changed

3 files changed

+2
-71
lines changed

packages/backend/src/api/replicache.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import { githubOrgTable, githubRepoTable } from "@console/core/git/git.sql";
4646
import { slackTeam } from "@console/core/slack/slack.sql";
4747
import {
4848
stateCountTable,
49-
stateEventTable,
5049
stateResourceTable,
5150
stateUpdateTable,
5251
} from "@console/core/state/state.sql";

packages/core/src/state/index.ts

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { z } from "zod";
22
import { zod } from "../util/zod";
33
import {
44
stateUpdateTable,
5-
stateEventTable,
65
Action,
76
UpdateCommand,
87
Command,
@@ -11,10 +10,6 @@ import {
1110
stateCountTable,
1211
} from "./state.sql";
1312

14-
import {
15-
stateEventTable as pg_stateEventTable,
16-
stateUpdateTable as pg_stateUpdateTable,
17-
} from "./state.pg";
1813
import {
1914
createTransaction,
2015
createTransactionEffect,
@@ -36,7 +31,7 @@ import { Replicache } from "../replicache";
3631
import { app, stage } from "../app/app.sql";
3732
import { bus } from "sst/aws/bus";
3833
import { Resource as SSTResource } from "sst";
39-
import { map, mapValues, pipe, unique } from "remeda";
34+
import { map, pipe, unique } from "remeda";
4035
import { Enrichers } from "../app/resource";
4136
import { queue } from "../util/queue";
4237
import { DateTime } from "luxon";
@@ -47,7 +42,6 @@ import {
4742
import { runTable } from "../run/run.sql";
4843
import { objectFlatten } from "../util/object";
4944
import { logger } from "../util/log";
50-
import { postgres } from "../drizzle/postgres";
5145
import { disposable } from "../util/disposable";
5246

5347
export module State {
@@ -215,30 +209,6 @@ export module State {
215209
};
216210
}
217211

218-
export function serializeEvent(
219-
input: typeof stateEventTable.$inferSelect,
220-
): ResourceEvent {
221-
return {
222-
id: input.id,
223-
type: input.type,
224-
time: {
225-
created: input.timeCreated.toISOString(),
226-
updated: input.timeUpdated.toISOString(),
227-
deleted: input.timeDeleted?.toISOString(),
228-
stateCreated: input.timeStateCreated?.toISOString(),
229-
stateModified: input.timeStateModified?.toISOString(),
230-
},
231-
stageID: input.stageID,
232-
custom: input.custom,
233-
updateID: input.updateID,
234-
urn: input.urn,
235-
inputs: input.inputs,
236-
parent: input.parent || undefined,
237-
outputs: input.outputs,
238-
action: input.action,
239-
};
240-
}
241-
242212
export function serializeResource(
243213
input: typeof stateResourceTable.$inferSelect,
244214
): Resource {
@@ -378,7 +348,6 @@ export module State {
378348
previousState.resources.map((r: any) => [r.urn, r]),
379349
);
380350

381-
const eventInserts = [] as (typeof stateEventTable.$inferInsert)[];
382351
const resourceDeletes = [] as string[];
383352
const counts = {} as Record<string, number>;
384353
console.log({
@@ -423,44 +392,11 @@ export module State {
423392

424393
delete inputs["__provider"];
425394
delete outputs["__provider"];
426-
427-
eventInserts.push({
428-
stageID: input.config.stageID,
429-
updateID: updateID,
430-
id: createId(),
431-
timeStateModified: resource.modified
432-
? new Date(resource.modified)
433-
: null,
434-
timeStateCreated: resource.created
435-
? new Date(resource.created)
436-
: null,
437-
workspaceID: useWorkspace(),
438-
type: resource.type,
439-
urn: resource.urn,
440-
custom: resource.custom,
441-
inputs: inputs,
442-
outputs: outputs,
443-
parent: resource.parent,
444-
action: action,
445-
});
446395
}
447396
}
448397
for (const urn of Object.keys(previousResources)) {
449398
const resource = previousResources[urn];
450399
counts["deleted"] = (counts["deleted"] || 0) + 1;
451-
eventInserts.push({
452-
stageID: input.config.stageID,
453-
updateID,
454-
action: "deleted",
455-
id: createId(),
456-
workspaceID: useWorkspace(),
457-
type: resource.type,
458-
urn: resource.urn,
459-
custom: resource.custom,
460-
inputs: {},
461-
outputs: {},
462-
parent: resource.parent,
463-
});
464400
resourceDeletes.push(resource.urn);
465401
}
466402
await createTransaction(
@@ -480,8 +416,6 @@ export module State {
480416
eq(stateUpdateTable.id, updateID),
481417
),
482418
);
483-
if (eventInserts.length)
484-
await tx.insert(stateEventTable).ignore().values(eventInserts);
485419
if (resourceDeletes.length)
486420
await tx
487421
.delete(stateResourceTable)

packages/core/src/state/pg.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
createTransactionEffect,
2525
useTransaction,
2626
} from "../util/transaction";
27-
import { stateEventTable, stateUpdateTable } from "./state.sql";
27+
import { stateUpdateTable, stateEventTable } from "./state.sql";
2828
import { Replicache } from "../replicache";
2929
import { mapValues } from "remeda";
3030
import { stage } from "../app/app.sql";
@@ -450,8 +450,6 @@ export const stateReceiveSnapshot = zod(
450450
eq(stateUpdateTable.id, input.updateID),
451451
),
452452
);
453-
if (eventInserts.length)
454-
await tx.insert(stateEventTable).ignore().values(eventInserts);
455453
await tx
456454
.update(stage)
457455
.set({

0 commit comments

Comments
 (0)