Skip to content

Sc 374 remove timestamp from daily statistics tables date column and correct sort order#847

Open
nbeatty-gpa wants to merge 3 commits intomasterfrom
SC-374-Remove-timestamp-from-Daily-Statistics-tables-Date-column-and-correct-sort-order
Open

Sc 374 remove timestamp from daily statistics tables date column and correct sort order#847
nbeatty-gpa wants to merge 3 commits intomasterfrom
SC-374-Remove-timestamp-from-Daily-Statistics-tables-Date-column-and-correct-sort-order

Conversation

@nbeatty-gpa
Copy link
Copy Markdown
Contributor

Jira Issue(s)

*

SC-374



Description

Fix the ordering callback to sort by date



How/Where to test OR Detail how it was tested

  1. Navigate to the Device Health Report page
  2. Select a status column
  3. Check the miMD and openXDA tabs
  4. verify that sorting by any column works properly.

@elwills elwills requested a review from Copilot April 8, 2026 20:40
@elwills elwills self-assigned this Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the SystemCenter “Daily Statistics” tables to correct client-side sorting behavior (notably for the Date column) on the OpenXDA and miMD tabs of the Device Health Report page.

Changes:

  • Replaced _.orderBy with a _.sortBy-based ordering callback that treats Date as a moment-parsed value before sorting.
  • Adjusted sort direction handling by reversing the sorted array when descending.
  • Updated the OpenXDA page’s data-fetching effect dependencies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/DeviceIssuesPage/OpenXDAIssuesPage.tsx Changes sort logic to correctly sort by Date; also modifies the fetch effect dependency array.
Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/DeviceIssuesPage/MiMDIssuesPage.tsx Changes sort logic to correctly sort by Date.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (handle.abort != undefined) handle.abort();
}
}, [props.Meter.AssetKey]);
}, [props.Meter.AssetKey, ascending, sortField]);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The data-fetching effect is now re-running whenever ascending or sortField changes, which will trigger a new PagedSearch call on every client-side sort toggle. Since you already re-sort locally via the order callback (and the separate effect that runs when order changes), this dependency expansion adds unnecessary network load and can cause request abort/retry churn while the user is sorting.

Consider limiting this effect’s dependency array back to just props.Meter.AssetKey (and keep client-side sorting handled by the order/re-sort effect).

Suggested change
}, [props.Meter.AssetKey, ascending, sortField]);
}, [props.Meter.AssetKey]);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment is valid Solution does not align with the rest of the codebase.

React.useEffect(() => {
if (data.length === 0) return;
setData(order(data));
}, [order]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this seems counter intuitive. Everywhere else we just reFetch if order or ascending changes. Why are we doing it locally here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, I just made minimum changes to address the sorting bugs. I'll look into changing it to align more with the rest of the codebase

Comment on lines 52 to +63
@@ -58,7 +60,7 @@ function MiMDIssuesPage(props: { Meter: OpenXDA.Types.Meter }) {
return () => {
if (handle != null || handle.abort != null) handle.abort();
}
}, [props.Meter.AssetKey, sortField, ascending]);
}, [props.Meter.AssetKey]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot has a point, but I don't think the solution is right. We do ordering in the controller everywhere else. So (a) We should let the Controller do ordering here
(b) We should drop the local sort
(c) We should reFetch when sortField or ascending change.

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.

4 participants