clintropolis commented on code in PR #17521:
URL: https://github.com/apache/druid/pull/17521#discussion_r1861110456


##########
web-console/src/utils/date-floor-shift-ceil/date-floor-shift-ceil.ts:
##########
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { fromDate, startOfWeek } from '@internationalized/date';
+
+export type AlignFn = (dt: Date, tz: string) => Date;
+
+export type ShiftFn = (dt: Date, tz: string, step: number) => Date;
+
+export type RoundFn = (dt: Date, roundTo: number, tz: string) => Date;
+
+export interface TimeShifterNoCeil {
+  canonicalLength: number;

Review Comment:
   nit: should it be more obvious that this number is millis?



##########
web-console/src/components/segment-timeline/segment-bar-chart-render.tsx:
##########
@@ -0,0 +1,793 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Button, Intent } from '@blueprintjs/core';
+import type { NonNullDateRange } from '@blueprintjs/datetime';
+import { IconNames } from '@blueprintjs/icons';
+import IntervalTree from '@flatten-js/interval-tree';
+import classNames from 'classnames';
+import { max, sort, sum } from 'd3-array';
+import { axisBottom, axisLeft } from 'd3-axis';
+import { scaleLinear, scaleUtc } from 'd3-scale';
+import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
+import { useMemo, useRef, useState } from 'react';
+
+import type { Rule } from '../../druid-models';
+import { getDatasourceColor, RuleUtil } from '../../druid-models';
+import { useClock, useGlobalEventListener } from '../../hooks';
+import {
+  allSameValue,
+  arraysEqualByElement,
+  clamp,
+  day,
+  Duration,
+  formatBytes,
+  formatNumber,
+  groupBy,
+  groupByAsMap,
+  minute,
+  month,
+  pluralIfNeeded,
+  TZ_UTC,
+  uniq,
+} from '../../utils';
+import type { Margin, Stage } from '../../utils/stage';
+import type { PortalBubbleOpenOn } from '../portal-bubble/portal-bubble';
+import { PortalBubble } from '../portal-bubble/portal-bubble';
+
+import { ChartAxis } from './chart-axis';
+import type { IntervalBar, IntervalRow, IntervalStat, TrimmedIntervalRow } 
from './common';
+import { aggregateSegmentStats, formatIntervalStat, formatIsoDateOnly } from 
'./common';
+
+import './segment-bar-chart-render.scss';
+
+const CHART_MARGIN: Margin = { top: 20, right: 0, bottom: 25, left: 70 };
+const MIN_BAR_WIDTH = 4;
+const POSSIBLE_GRANULARITIES = [
+  new Duration('PT15M'),
+  new Duration('PT1H'),
+  new Duration('PT6H'),
+  new Duration('P1D'),
+  new Duration('P1M'),
+  new Duration('P1Y'),
+];
+
+const EXTEND_X_SCALE_DOMAIN_BY = 1;
+
+function formatStartDuration(start: Date, duration: Duration): string {
+  let sliceLength;
+  const { singleSpan } = duration;
+  switch (singleSpan) {
+    case 'year':
+      sliceLength = 4;
+      break;
+
+    case 'month':
+      sliceLength = 7;
+      break;
+
+    case 'day':
+      sliceLength = 10;
+      break;
+
+    case 'hour':
+      sliceLength = 13;
+      break;
+
+    case 'minute':
+      sliceLength = 16;
+      break;
+
+    default:
+      sliceLength = 19;
+      break;
+  }
+
+  return `${start.toISOString().slice(0, sliceLength)}/${duration}`;
+}
+
+// ---------------------------------------
+// Load rule stuff
+
+function loadRuleToBaseType(loadRule: Rule): string {
+  const m = /^(load|drop|broadcast)/.exec(loadRule.type);
+  return m ? m[1] : 'load';
+}
+
+const NEGATIVE_INFINITY_DATE = new Date(Date.UTC(1000, 0, 1));
+const POSITIVE_INFINITY_DATE = new Date(Date.UTC(3000, 0, 1));
+
+function loadRuleToDateRange(loadRule: Rule): NonNullDateRange {
+  switch (loadRule.type) {
+    case 'loadByInterval':
+    case 'dropByInterval':
+    case 'broadcastByInterval':
+      return String(loadRule.interval)
+        .split('/')
+        .map(d => new Date(d)) as NonNullDateRange;
+
+    case 'loadByPeriod':
+    case 'dropByPeriod':
+    case 'broadcastByPeriod':
+      return [
+        new Duration(loadRule.period || 'P1D').shift(new Date(), TZ_UTC, -1),
+        loadRule.includeFuture ? POSITIVE_INFINITY_DATE : new Date(),
+      ];
+
+    case 'dropBeforeByPeriod':
+      return [
+        NEGATIVE_INFINITY_DATE,
+        new Duration(loadRule.period || 'P1D').shift(new Date(), TZ_UTC, -1),
+      ];
+
+    default:
+      return [NEGATIVE_INFINITY_DATE, POSITIVE_INFINITY_DATE];
+  }
+}
+
+// ---------------------------------------
+
+function offsetDateRange(dateRange: NonNullDateRange, offset: number): 
NonNullDateRange {
+  return [new Date(dateRange[0].valueOf() + offset), new 
Date(dateRange[1].valueOf() + offset)];
+}
+
+function stackIntervalRows(trimmedIntervalRows: TrimmedIntervalRow[]): {
+  intervalBars: IntervalBar[];
+  intervalTree: IntervalTree;
+} {
+  // Total size of the datasource will be user as an ordering tiebreaker

Review Comment:
   nit:
   ```suggestion
     // Total size of the datasource will be used as an ordering tiebreaker
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to