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 @@
1import { Cause, Exit, Result, Schema } from "effect";1import { Cause, DateTime, Exit, Option, Result, Schema } from "effect";
2import { PositiveInt, TrimmedNonEmptyString } from "@t3tools/contracts";2import { PositiveInt, TrimmedNonEmptyString } from "@t3tools/contracts";
3import { decodeJsonResult, formatSchemaError } from "@t3tools/shared/schemaJson";3import { decodeJsonResult, formatSchemaError } from "@t3tools/shared/schemaJson";
4 4
@@ -9,7 +9,7 @@ export interface NormalizedGitHubPullRequestRecord { · 4 unmodified lines
9 readonly baseRefName: string;9 readonly baseRefName: string;
10 readonly headRefName: string;10 readonly headRefName: string;
11 readonly state: "open" | "closed" | "merged";11 readonly state: "open" | "closed" | "merged";
12 readonly updatedAt: string | null;12 readonly updatedAt: Option.Option<DateTime.Utc>;
13 readonly isCrossRepository?: boolean;13 readonly isCrossRepository?: boolean;
14 readonly headRepositoryNameWithOwner?: string | null;14 readonly headRepositoryNameWithOwner?: string | null;
15 readonly headRepositoryOwnerLogin?: string | null;15 readonly headRepositoryOwnerLogin?: string | null;
@@ -23,7 +23,7 @@ const GitHubPullRequestSchema = Schema.Struct({ · 7 unmodified lines
23 headRefName: TrimmedNonEmptyString,23 headRefName: TrimmedNonEmptyString,
24 state: Schema.optional(Schema.NullOr(Schema.String)),24 state: Schema.optional(Schema.NullOr(Schema.String)),
25 mergedAt: Schema.optional(Schema.NullOr(Schema.String)),25 mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
26 updatedAt: Schema.optional(Schema.NullOr(Schema.String)),26 updatedAt: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
27 isCrossRepository: Schema.optional(Schema.Boolean),27 isCrossRepository: Schema.optional(Schema.Boolean),
28 headRepository: Schema.optional(28 headRepository: Schema.optional(
29 Schema.NullOr(29 Schema.NullOr(
@@ -80,8 +80,7 @@ function normalizeGitHubPullRequestRecord( · 50 unmodified lines
80 baseRefName: raw.baseRefName,80 baseRefName: raw.baseRefName,
81 headRefName: raw.headRefName,81 headRefName: raw.headRefName,
82 state: normalizeGitHubPullRequestState(raw),82 state: normalizeGitHubPullRequestState(raw),
83 updatedAt:83 updatedAt: raw.updatedAt ?? Option.none(),
84 typeof raw.updatedAt === "string" && raw.updatedAt.trim().length > 0 ? raw.updatedAt : null,
85 ...(typeof raw.isCrossRepository === "boolean"84 ...(typeof raw.isCrossRepository === "boolean"
86 ? { isCrossRepository: raw.isCrossRepository }85 ? { isCrossRepository: raw.isCrossRepository }
87 : {}),86 : {}),

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