Skip to content

Commit ff1aa00

Browse files
committed
simplify
1 parent 05ce130 commit ff1aa00

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

apps/webapp/app/services/runsReplicationService.server.ts

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ClickHouse } from "@internal/clickhouse";
2-
import { TASK_RUN_COLUMNS, PAYLOAD_COLUMNS } from "@internal/clickhouse";
32
import { type RedisOptions } from "@internal/redis";
43
import {
54
LogicalReplicationClient,
@@ -760,14 +759,14 @@ export class RunsReplicationService {
760759
#getClickhouseInsertSettings() {
761760
if (this._insertStrategy === "insert") {
762761
return {};
763-
} else if (this._insertStrategy === "insert_async") {
764-
return {
765-
async_insert: 1 as const,
766-
async_insert_max_data_size: "1000000",
767-
async_insert_busy_timeout_ms: 1000,
768-
wait_for_async_insert: this.options.waitForAsyncInsert ? (1 as const) : (0 as const),
769-
};
770762
}
763+
764+
return {
765+
async_insert: 1 as const,
766+
async_insert_max_data_size: "1000000",
767+
async_insert_busy_timeout_ms: 1000,
768+
wait_for_async_insert: this.options.waitForAsyncInsert ? (1 as const) : (0 as const),
769+
};
771770
}
772771

773772
async #insertTaskRunInserts(taskRunInserts: any[][], attempt: number) {
@@ -825,18 +824,8 @@ export class RunsReplicationService {
825824

826825
const { run, _version, event } = batchedRun;
827826

828-
if (!run.environmentType) {
829-
return {
830-
taskRunInsert: undefined,
831-
payloadInsert: undefined,
832-
};
833-
}
834-
835-
if (!run.organizationId) {
836-
return {
837-
taskRunInsert: undefined,
838-
payloadInsert: undefined,
839-
};
827+
if (!run.environmentType || !run.organizationId) {
828+
return {};
840829
}
841830

842831
if (event === "update" || event === "delete" || this._disablePayloadInsert) {
@@ -848,21 +837,15 @@ export class RunsReplicationService {
848837
_version
849838
);
850839

851-
return {
852-
taskRunInsert,
853-
payloadInsert: undefined,
854-
};
840+
return { taskRunInsert };
855841
}
856842

857843
const [taskRunInsert, payloadInsert] = await Promise.all([
858844
this.#prepareTaskRunInsert(run, run.organizationId, run.environmentType, event, _version),
859845
this.#preparePayloadInsert(run, _version),
860846
]);
861847

862-
return {
863-
taskRunInsert,
864-
payloadInsert,
865-
};
848+
return { taskRunInsert, payloadInsert };
866849
}
867850

868851
async #prepareTaskRunInsert(

internal-packages/clickhouse/src/client/client.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -900,24 +900,18 @@ export class ClickhouseClient implements ClickhouseReader, ClickhouseWriter {
900900
}
901901
}
902902

903-
function recordClickhouseError(span: Span, error: Error) {
903+
function recordClickhouseError(span: Span, error: Error): void {
904904
if (error instanceof ClickHouseError) {
905905
span.setAttributes({
906906
"clickhouse.error.code": error.code,
907907
"clickhouse.error.message": error.message,
908908
"clickhouse.error.type": error.type,
909909
});
910-
recordSpanError(span, error);
911-
} else {
912-
recordSpanError(span, error);
913910
}
911+
recordSpanError(span, error);
914912
}
915913

916-
function convertLogLevelToClickhouseLogLevel(logLevel?: LogLevel) {
917-
if (!logLevel) {
918-
return ClickHouseLogLevel.INFO;
919-
}
920-
914+
function convertLogLevelToClickhouseLogLevel(logLevel?: LogLevel): ClickHouseLogLevel {
921915
switch (logLevel) {
922916
case "debug":
923917
return ClickHouseLogLevel.DEBUG;

0 commit comments

Comments
 (0)