GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): honor sort: 'created' when merging IssueService.list ent… · pingdotgg/t3code@c2477b0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/issue
    • IssueService.test.ts
    • IssueService.ts
  • packages/contracts/src
    • issue.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/issue/IssueService.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/issue/IssueService.test.ts
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,4 +913,60 @@ describe("IssueService with a standalone tracker", () => {
913913
});
914914
}),
915915
);
916+
917+
it.effect("orders merged entries by createdAt when sort is created and updatedAt otherwise", () =>
918+
Effect.gen(function* () {
919+
const seenSorts: string[] = [];
920+
const service = yield* makeService({
921+
projects: [
922+
project({ id: "web", repository: "acme/web" }),
923+
project({ id: "api", repository: "acme/api" }),
924+
],
925+
trackers: [
926+
fakeTracker({
927+
listIssues: (input) => {
928+
seenSorts.push(input.sort);
929+
if (input.scope === "acme/web") {
930+
return Effect.succeed({
931+
items: [
932+
{
933+
...issue("old-created-recent-update"),
934+
createdAt: "2026-07-06T01:00:00+02:00",
935+
updatedAt: "2026-07-10T00:00:00Z",
936+
},
937+
],
938+
nextCursor: null,
939+
});
940+
}
941+
return Effect.succeed({
942+
items: [
943+
{
944+
...issue("new-created-older-update"),
945+
createdAt: "2026-07-05T23:30:00Z",
946+
updatedAt: "2026-07-06T00:00:00Z",
947+
},
948+
],
949+
nextCursor: null,
950+
});
951+
},
952+
}),
953+
],
954+
});
955+
956+
const byCreated = yield* service.list({ state: "open", sort: "created" });
957+
expect(seenSorts).toEqual(["created", "created"]);
958+
expect(byCreated.entries.map((entry) => entry.key)).toEqual([
959+
"new-created-older-update",
960+
"old-created-recent-update",
961+
]);
962+
963+
seenSorts.length = 0;
964+
const byUpdated = yield* service.list({ state: "open" });
965+
expect(seenSorts).toEqual(["updated", "updated"]);
966+
expect(byUpdated.entries.map((entry) => entry.key)).toEqual([
967+
"old-created-recent-update",
968+
"new-created-older-update",
969+
]);
970+
}),
971+
);
916972
});
Collapse file

‎apps/server/src/issue/IssueService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/issue/IssueService.ts
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ const make = Effect.gen(function* () {
380380
const nextCursors: Record<string, string> = {};
381381

382382
const involvement = input.involvement ?? "all";
383+
const sort = input.sort ?? "updated";
383384
// Only a narrowed listing compares against the signed-in account; `all` never reads it.
384385
const viewerRequests = new Map<string, Effect.Effect<string, IssueTrackerError>>();
385386
for (const project of involvement === "all" ? [] : scopes.values()) {
@@ -454,7 +455,7 @@ const make = Effect.gen(function* () {
454455
query: input.query,
455456
labels: input.labels,
456457
assignee: input.assignee,
457-
sort: input.sort ?? "updated",
458+
sort,
458459
cursor,
459460
refresh: input.refresh,
460461
}),
@@ -509,7 +510,17 @@ const make = Effect.gen(function* () {
509510
detail: "Issues cannot be browsed for this host yet.",
510511
});
511512
}
512-
entries.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
513+
const sortField = sort === "created" ? "createdAt" : "updatedAt";
514+
const parseSortTime = (iso: string) => {
515+
const time = Date.parse(iso);
516+
return Number.isNaN(time) ? Number.NEGATIVE_INFINITY : time;
517+
};
518+
entries.sort((a, b) => {
519+
const aTime = parseSortTime(a[sortField]);
520+
const bTime = parseSortTime(b[sortField]);
521+
if (aTime !== bTime) return bTime > aTime ? 1 : -1;
522+
return b[sortField].localeCompare(a[sortField]);
523+
});
513524
return {
514525
viewers: Object.fromEntries(viewers),
515526
trackers: [...trackers.values()],
Collapse file

‎packages/contracts/src/issue.ts‎

Copy file name to clipboardExpand all lines: packages/contracts/src/issue.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export const IssueListResult = Schema.Struct({
332332
/** The signed-in account per host that involvement compared against. Empty for `all`. */
333333
viewers: Schema.Record(TrimmedNonEmptyString, TrimmedNonEmptyString),
334334
trackers: Schema.Array(IssueTrackerSummary),
335-
/** By update, newest first, across every scope this answer covers. */
335+
/** Newest first by the requested `sort` (`updated` when absent), across every scope this answer covers. */
336336
entries: Schema.Array(IssueListEntry),
337337
errors: Schema.Array(IssueListProjectError),
338338
/** Where each scope carries on, sent straight back as `cursors`. Absent once a scope is done. */

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.