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
5 changes: 5 additions & 0 deletions apps/docs/cost-analytics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ model and provider. The source also appears in the detail drilldown. Choose a
time range before comparing periods so the chart and breakdown use the same
window.

Analytics date presets and daily chart buckets use the web server's timezone,
including daylight-saving transitions. Costs, Tasks, and PR analytics use the
same calendar-day boundaries; these are not based on each viewer's browser
timezone or the deployment's automation scheduling timezone.

## Exporting data

Select **Download data** to export the currently filtered detail rows as a CSV
Expand Down
9 changes: 1 addition & 8 deletions apps/web/src/lib/server/analytics/time-buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ export function getRequestTimeBootstrapCutoff(
timePeriod: TimePeriodFilter | undefined,
now: Date,
): Date | null {
if (!timePeriod || timePeriod === 'all') {
return null;
}

const cutoff = new Date(now);
cutoff.setUTCHours(0, 0, 0, 0);
cutoff.setUTCDate(cutoff.getUTCDate() - (timePeriod - 1));
return cutoff;
return getTimeCutoff(timePeriod, now);
}

export function getResolvedGranularity(
Expand Down
96 changes: 96 additions & 0 deletions apps/web/src/lib/server/pull-request-facts.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions apps/web/src/lib/server/pull-request-facts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@ import {
} from '@roomote/db/server';

import type { TimePeriodFilter } from '@/types';

function getTimeCutoff(
timePeriod: TimePeriodFilter | undefined,
now: Date,
): Date | null {
if (!timePeriod || timePeriod === 'all') {
return null;
}

const cutoff = new Date(now);
cutoff.setUTCHours(0, 0, 0, 0);
cutoff.setUTCDate(cutoff.getUTCDate() - (timePeriod - 1));
return cutoff;
}
import { getTimeCutoff } from './analytics/time-buckets';

export async function getStoredPullRequestsForAnalytics(params: {
repositoryIds: string[];
Expand Down
Loading