pierrejeambrun commented on code in PR #55339:
URL: https://github.com/apache/airflow/pull/55339#discussion_r2355576449
##########
airflow-core/src/airflow/ui/src/components/DurationChart.tsx:
##########
@@ -114,6 +118,24 @@ export const DurationChart = ({
value: (ctx: PartialEventContext) => average(ctx, 0),
};
+ const getLabelFormat = (entries: Array<RunResponse>) => {
+ const timestamps = entries.map(entry => dayjs(entry.run_after));
+ const minTime = dayjs.min(timestamps);
+ const maxTime = dayjs.max(timestamps);
+
+ // satisfy null typecheck for dayjs.min/max
+ if (minTime === null || maxTime === null) {
+ return "MM-DD";
+ }
+ const diffInDays = maxTime.diff(minTime, 'days');
+
+ if (diffInDays < 1) {
+ return "hh:mm:ss"
+ } else {
+ return "MM-DD"
+ }
+ };
+
Review Comment:
Can you move this function outside of the component, so we do not redefine
it on every render.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]