Skip to content

Commit d92b140

Browse files
evanpurkhiserandrewshie-sentry
authored andcommitted
fix(crons): Fix MockCheckInTimeline positioning to match real timeline behavior (#103264)
The mock timeline was calculating positions incorrectly, causing misalignment with the grid lines. This fix makes it match how the real CheckInTimeline positions ticks. Key changes: 1. Use `periodStart` instead of `start` (which is underscanStart) as the base timestamp calculations 2. Add `startOffset` (underscanWidth) to all positions to account for the underscan area on the left 3. Use `elapsedMinutes` from the config for consistency with grid calculations 4. Use `timelineWidth` which excludes the underscan width This matches the positioning logic in mergeBuckets where ticks are positioned relative to the usable timeline area, not the full container width.
1 parent 3a9ecd5 commit d92b140

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

static/app/components/checkInTimeline/checkInTimeline.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ interface CheckInTimelineProps<Status extends string>
4444
makeUnit?: (count: number) => React.ReactNode;
4545
}
4646

47-
function getBucketedCheckInsPosition(
48-
timestamp: number,
49-
timelineStart: Date,
50-
msPerPixel: number
51-
) {
52-
const elapsedSinceStart = new Date(timestamp).getTime() - timelineStart.getTime();
53-
return elapsedSinceStart / msPerPixel;
54-
}
55-
5647
export function CheckInTimeline<Status extends string>({
5748
bucketedData,
5849
timeWindowConfig,
@@ -109,21 +100,31 @@ interface MockCheckInTimelineProps<Status extends string>
109100
status: Status;
110101
}
111102

103+
function getBucketedCheckInsPosition(
104+
timestamp: number,
105+
timelineStart: Date,
106+
msPerPixel: number
107+
) {
108+
const elapsedSinceStart = new Date(timestamp).getTime() - timelineStart.getTime();
109+
return elapsedSinceStart / msPerPixel;
110+
}
111+
112112
export function MockCheckInTimeline<Status extends string>({
113113
mockTimestamps,
114114
timeWindowConfig,
115115
status,
116116
statusStyle,
117117
}: MockCheckInTimelineProps<Status>) {
118-
const {start, end} = timeWindowConfig;
119-
const elapsedMs = end.getTime() - start.getTime();
120-
const msPerPixel = elapsedMs / timeWindowConfig.timelineWidth;
118+
const {periodStart, elapsedMinutes, timelineWidth, rollupConfig} = timeWindowConfig;
119+
const msPerPixel = (elapsedMinutes * 60 * 1000) / timelineWidth;
120+
const startOffset = rollupConfig.timelineUnderscanWidth;
121121

122122
return (
123123
<TimelineContainer>
124124
{mockTimestamps.map(ts => {
125125
const timestampMs = ts.getTime();
126-
const left = getBucketedCheckInsPosition(timestampMs, start, msPerPixel);
126+
const left =
127+
startOffset + getBucketedCheckInsPosition(timestampMs, periodStart, msPerPixel);
127128

128129
return (
129130
<Tooltip

static/app/components/checkInTimeline/types.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export interface TimeWindowConfig {
9090
start: Date;
9191
/**
9292
* The width in pixels of the timeline. This value is clamped such that there
93-
* may be some underscan. See the RollupConfig for more details.
93+
* may be some underscan, this value does not include the width of the
94+
* underscan. See the RollupConfig for more details.
9495
*/
9596
timelineWidth: number;
9697
}

0 commit comments

Comments
 (0)