Skip to content

Commit 3f61538

Browse files
juliusmarmingecodex
andcommitted
refactor(server): collect decoded runtime rows once
Use Effect Array.filterMap to discard skipped rows and unwrap successful decodes in a single traversal. Co-authored-by: codex <[email protected]>
1 parent 2f3904a commit 3f61538

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/server/src/persistence/ProviderSessionRuntime.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import * as Arr from "effect/Array";
12
import * as Context from "effect/Context";
23
import * as Effect from "effect/Effect";
34
import * as Layer from "effect/Layer";
45
import * as Option from "effect/Option";
6+
import * as Result from "effect/Result";
57
import * as Schema from "effect/Schema";
68
import * as Struct from "effect/Struct";
79
import * as SqlClient from "effect/unstable/sql/SqlClient";
@@ -299,7 +301,11 @@ export const make = Effect.gen(function* () {
299301
),
300302
),
301303
),
302-
Effect.map((decoded) => decoded.filter(Option.isSome).map((row) => row.value)),
304+
Effect.map((decoded) =>
305+
Arr.filterMap(decoded, (row) =>
306+
Option.isSome(row) ? Result.succeed(row.value) : Result.failVoid,
307+
),
308+
),
303309
);
304310

305311
const deleteByThreadId: ProviderSessionRuntimeRepository["Service"]["deleteByThreadId"] = (

0 commit comments

Comments
 (0)