History

Normalize timestamps across VCS and source control contracts

- Switch freshness and PR update times to typed `DateTime`/`Option` values - Update GitHub and VCS adapters, tests, and sorting to use the new shapes

Julius Marminge committed 6 months ago

Commit 6d7de0b1 parent 38185dc9 files · +51 −34Browse files

Showing the changes to apps/server/src/git/githubPullRequests.ts (1 of 9 files). Show all

Unified · Split

apps/server/src/git/githubPullRequests.ts+4−5
@@ -1,4 +1,4 @@
1−import { Cause, Exit, Result, Schema } from "effect";
1+import { Cause, DateTime, Exit, Option, Result, Schema } from "effect";
22 import { PositiveInt, TrimmedNonEmptyString } from "@t3tools/contracts";
33 import { decodeJsonResult, formatSchemaError } from "@t3tools/shared/schemaJson";
44
@@ -9,7 +9,7 @@ export interface NormalizedGitHubPullRequestRecord { · 4 unmodified lines
99 readonly baseRefName: string;
1010 readonly headRefName: string;
1111 readonly state: "open" | "closed" | "merged";
12− readonly updatedAt: string | null;
12+ readonly updatedAt: Option.Option<DateTime.Utc>;
1313 readonly isCrossRepository?: boolean;
1414 readonly headRepositoryNameWithOwner?: string | null;
1515 readonly headRepositoryOwnerLogin?: string | null;
@@ -23,7 +23,7 @@ const GitHubPullRequestSchema = Schema.Struct({ · 7 unmodified lines
2323 headRefName: TrimmedNonEmptyString,
2424 state: Schema.optional(Schema.NullOr(Schema.String)),
2525 mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
26− updatedAt: Schema.optional(Schema.NullOr(Schema.String)),
26+ updatedAt: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
2727 isCrossRepository: Schema.optional(Schema.Boolean),
2828 headRepository: Schema.optional(
2929 Schema.NullOr(
@@ -80,8 +80,7 @@ function normalizeGitHubPullRequestRecord( · 50 unmodified lines
8080 baseRefName: raw.baseRefName,
8181 headRefName: raw.headRefName,
8282 state: normalizeGitHubPullRequestState(raw),
83− updatedAt:
84− typeof raw.updatedAt === "string" && raw.updatedAt.trim().length > 0 ? raw.updatedAt : null,
83+ updatedAt: raw.updatedAt ?? Option.none(),
8584 ...(typeof raw.isCrossRepository === "boolean"
8685 ? { isCrossRepository: raw.isCrossRepository }
8786 : {}),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t