Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions static/app/components/checkInTimeline/checkInTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ interface CheckInTimelineProps<Status extends string>
makeUnit?: (count: number) => React.ReactNode;
}

function getBucketedCheckInsPosition(
timestamp: number,
timelineStart: Date,
msPerPixel: number
) {
const elapsedSinceStart = new Date(timestamp).getTime() - timelineStart.getTime();
return elapsedSinceStart / msPerPixel;
}

export function CheckInTimeline<Status extends string>({
bucketedData,
timeWindowConfig,
Expand Down Expand Up @@ -109,21 +100,31 @@ interface MockCheckInTimelineProps<Status extends string>
status: Status;
}

function getBucketedCheckInsPosition(
timestamp: number,
timelineStart: Date,
msPerPixel: number
) {
const elapsedSinceStart = new Date(timestamp).getTime() - timelineStart.getTime();
return elapsedSinceStart / msPerPixel;
}

export function MockCheckInTimeline<Status extends string>({
mockTimestamps,
timeWindowConfig,
status,
statusStyle,
}: MockCheckInTimelineProps<Status>) {
const {start, end} = timeWindowConfig;
const elapsedMs = end.getTime() - start.getTime();
const msPerPixel = elapsedMs / timeWindowConfig.timelineWidth;
const {periodStart, elapsedMinutes, timelineWidth, rollupConfig} = timeWindowConfig;
const msPerPixel = (elapsedMinutes * 60 * 1000) / timelineWidth;
const startOffset = rollupConfig.timelineUnderscanWidth;

return (
<TimelineContainer>
{mockTimestamps.map(ts => {
const timestampMs = ts.getTime();
const left = getBucketedCheckInsPosition(timestampMs, start, msPerPixel);
const left =
startOffset + getBucketedCheckInsPosition(timestampMs, periodStart, msPerPixel);

return (
<Tooltip
Expand Down
3 changes: 2 additions & 1 deletion static/app/components/checkInTimeline/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export interface TimeWindowConfig {
start: Date;
/**
* The width in pixels of the timeline. This value is clamped such that there
* may be some underscan. See the RollupConfig for more details.
* may be some underscan, this value does not include the width of the
* underscan. See the RollupConfig for more details.
*/
timelineWidth: number;
}
Expand Down
Loading