Skip to content

Conversation

@keshxvdayal
Copy link
Contributor

@keshxvdayal keshxvdayal commented Dec 17, 2025

Description

Fixes #(issue)

Checklist

  • My code follows the contributing guidelines of this project.
  • I am aware that all my commits will be squashed into a single commit, using the PR title as the commit message.
  • I have performed a self-review of my own code.
  • I have commented my code in hard-to-understand areas.
  • I have updated the user-facing documentation to describe any new or changed behavior.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have not reduced the existing code coverage.

Comments

Summary by Sourcery

Sort GA4GH DRS objects by most recently updated and enrich the objects list table with explicit created/last-updated timestamps.

New Features:

  • Display a Last Updated timestamp column for DRS objects alongside their creation time.

Enhancements:

  • Sort DRS objects in the list by last update time (falling back to creation time) in reverse chronological order.
  • Show precise date and time for object creation and last update instead of date-only formatting.
  • Adjust objects list table layout and skeleton widths to accommodate the new timestamps and removed actions column.

@changeset-bot
Copy link

changeset-bot bot commented Dec 17, 2025

⚠️ No Changeset found

Latest commit: 4cc183d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
elixir-cloud-components Ready Ready Preview, Comment Dec 23, 2025 1:23pm

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 17, 2025

Reviewer's Guide

Sorts GA4GH DRS objects by last-updated timestamp and updates the datasets table layout to show created/last-updated timestamps with adjusted column widths and skeleton placeholders.

Sequence diagram for loading and sorting GA4GH DRS objects

sequenceDiagram
  actor User
  participant ECCClientGa4ghDrsObjects
  participant DrsApi

  User->>ECCClientGa4ghDrsObjects: triggerLoadData
  activate ECCClientGa4ghDrsObjects
  ECCClientGa4ghDrsObjects->>DrsApi: fetchObjects(pageSize, currentPage - 1)
  activate DrsApi
  DrsApi-->>ECCClientGa4ghDrsObjects: objectsResult
  deactivate DrsApi
  ECCClientGa4ghDrsObjects->>ECCClientGa4ghDrsObjects: sortObjectsByLastUpdated(objectsResult.objects)
  ECCClientGa4ghDrsObjects->>ECCClientGa4ghDrsObjects: update objects and pagination
  ECCClientGa4ghDrsObjects-->>User: renderTableWithSortedTimestamps
  deactivate ECCClientGa4ghDrsObjects
Loading

Updated class diagram for ECCClientGa4ghDrsObjects component

classDiagram
  class ECCClientGa4ghDrsObjects {
    +objects DrsObject[]
    +pageSize number
    +currentPage number
    +loadData() void
    +render() unknown
    +renderPagination() unknown
    +handleObjectSelect(objectId string) void
    +bytesToSize(bytes number) string
    +formatDateTime(dateString string) string
    +sortObjectsByLastUpdated(objects DrsObject[]) DrsObject[]
  }

  class DrsObject {
    +id string
    +name string
    +size number
    +created_time string
    +updated_time string
  }

  ECCClientGa4ghDrsObjects "*" --> "*" DrsObject : displays
Loading

File-Level Changes

Change Details Files
Sort objects by last updated timestamp when loading data.
  • Wrap the fetched objects in a new static helper that sorts by updated_time, falling back to created_time.
  • Use reverse chronological ordering so the most recently updated objects appear first.
packages/ecc-client-ga4gh-drs/src/components/objects-list/objects.ts
Update table structure, column widths, and skeletons to show created and last updated timestamps instead of an actions column.
  • Adjust table column width classes for object info, size, created, and last updated columns, including matching skeleton layout and the empty-state colspan.
  • Replace the actions column with a new 'Last Updated' column bound to updated_time or created_time.
  • Introduce a formatDateTime helper that renders full date and time in en-US locale with 24-hour format, and use it for created and last updated cells instead of the previous date-only formatter.
  • Remove the inline actions slot/button from each row that previously showed a 'View Details' button.
packages/ecc-client-ga4gh-drs/src/components/objects-list/objects.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • In sortObjectsByLastUpdated, consider explicitly handling cases where both updated_time and created_time are missing to avoid calling new Date(undefined) and getting unexpected ordering or NaN values.
  • The new formatDateTime helper hardcodes an en-US 24‑hour format; if this component is used in different locales, it may be better to accept a locale/format option or use the runtime’s default locale for consistency with the rest of the app.
  • The table column previously used a slot for actions (actions-${object.id}) but now shows Last Updated instead; if callers currently rely on that slot for interactive controls, consider either preserving the slot in another column or documenting/removing that extension point more deliberately.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `sortObjectsByLastUpdated`, consider explicitly handling cases where both `updated_time` and `created_time` are missing to avoid calling `new Date(undefined)` and getting unexpected ordering or `NaN` values.
- The new `formatDateTime` helper hardcodes an `en-US` 24‑hour format; if this component is used in different locales, it may be better to accept a locale/format option or use the runtime’s default locale for consistency with the rest of the app.
- The table column previously used a slot for actions (`actions-${object.id}`) but now shows `Last Updated` instead; if callers currently rely on that slot for interactive controls, consider either preserving the slot in another column or documenting/removing that extension point more deliberately.

## Individual Comments

### Comment 1
<location> `packages/ecc-client-ga4gh-drs/src/components/objects-list/objects.ts:171-178` </location>
<code_context>
     this.loadData();
   }

+  private static sortObjectsByLastUpdated(objects: DrsObject[]): DrsObject[] {
+    return [...objects].sort((a, b) => {
+      // Use updated_time if available, otherwise fall back to created_time
+      const aTime = a.updated_time || a.created_time;
+      const bTime = b.updated_time || b.created_time;
+
+      // Sort in reverse chronological order (most recent first)
+      return new Date(bTime).getTime() - new Date(aTime).getTime();
+    });
+  }
</code_context>

<issue_to_address>
**issue:** Consider handling missing/invalid timestamps more defensively in the sort comparator.

If `updated_time`/`created_time` is missing or not a valid date, `new Date(...).getTime()` returns `NaN`, and comparisons with `NaN` can produce non‑deterministic ordering. Consider explicitly handling falsy/invalid timestamps (e.g., normalizing them to a sentinel like `0`/`-Infinity` or special‑casing when `aTime`/`bTime` is invalid) so those entries are consistently placed at the start or end of the list.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 171 to 178
private static sortObjectsByLastUpdated(objects: DrsObject[]): DrsObject[] {
return [...objects].sort((a, b) => {
// Use updated_time if available, otherwise fall back to created_time
const aTime = a.updated_time || a.created_time;
const bTime = b.updated_time || b.created_time;

// Sort in reverse chronological order (most recent first)
return new Date(bTime).getTime() - new Date(aTime).getTime();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Consider handling missing/invalid timestamps more defensively in the sort comparator.

If updated_time/created_time is missing or not a valid date, new Date(...).getTime() returns NaN, and comparisons with NaN can produce non‑deterministic ordering. Consider explicitly handling falsy/invalid timestamps (e.g., normalizing them to a sentinel like 0/-Infinity or special‑casing when aTime/bTime is invalid) so those entries are consistently placed at the start or end of the list.

@keshxvdayal keshxvdayal changed the title UP-879: Datasets improvements fixed feat: UP-879: Datasets improvements fixed Dec 17, 2025
@keshxvdayal keshxvdayal changed the title feat: UP-879: Datasets improvements fixed feat: up-879: Datasets improvements fixed Dec 17, 2025
Comment on lines 102 to 104
this.objects = ECCClientGa4ghDrsObjects.sortObjectsByLastUpdated(
result.objects
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect as the sorting should be handled on the backend.

Comment on lines 175 to 187
private static sortObjectsByLastUpdated(objects: DrsObject[]): DrsObject[] {
return [...objects].sort((a, b) => {
const aTime = a.updated_time || a.created_time;
const bTime = b.updated_time || b.created_time;

if (!aTime && !bTime) return 0;
if (!aTime) return 1;
if (!bTime) return -1;

return new Date(bTime).getTime() - new Date(aTime).getTime();
});
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same!

Comment on lines +363 to 379
private static formatDateTime(dateString: string): string {
try {
return new Date(dateString).toLocaleDateString();
if (!dateString) return "—";

return new Date(dateString).toLocaleString(undefined, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
});
} catch {
return dateString;
return dateString || "—";
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can open the slot rather than controlling this functionality. Like what is done with the title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants