mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 01:26:23 +00:00
fix: analytics post release bugs (#6291)
* fix: previous period data was included in the table * fix: revenue displaying stale data when viewing it from different metric and grouped by 6 hour or 1 hour * fix: remove staletime on analytics query so switching tabs does not refersh query * feat: add monetization alert * fix-small: missing space in tooltip * fix: incorrect y-axis formatting for trailing decimal 0s * fix: switching tabs resets table series selection due to other refetches * fix: always show month first in chart tooltip * fix: change all time start date to be project published date * fix: increase length on project name column * fix: unknown download source data points not showing for download source breakdown * fix: double unknown for loader * fix: no data on country labeling incorrectly as "Unknown" instead of "Other" * fix: date picker number inputs showing arrows * fix: stat card showing enormous percentage for prev period by switching it to absolute value difference after 1000% * fix: decimal values for playtime being rounded badly, resulting in 0.04 becoming 0.0 * fix: chips having stroke * refactor: pnpm prepr * fix: spacing in annoucement link * fix: legend scroll shadow on top of event tooltip
This commit is contained in:
@@ -52,6 +52,7 @@ const {
|
||||
selectedCustomTimeframeEndDate,
|
||||
selectedGroupBy,
|
||||
queryRefreshTimestamp,
|
||||
analyticsAllTimeStartDate,
|
||||
refreshAnalyticsQuery,
|
||||
} = injectAnalyticsDashboardContext()
|
||||
|
||||
@@ -107,6 +108,7 @@ function handleTimeframeDraftChange(selection: TimeFramePickerSelection) {
|
||||
customStartDate: selection.customStartDate,
|
||||
customEndDate: selection.customEndDate,
|
||||
nowTimestamp: queryRefreshTimestamp.value,
|
||||
allTimeStartDate: analyticsAllTimeStartDate.value,
|
||||
})
|
||||
const { start, end } = ensureMinimumTimeRange(range.start, range.end)
|
||||
const durationMinutes = Math.max(1, Math.floor((end.getTime() - start.getTime()) / 60000))
|
||||
|
||||
@@ -894,12 +894,6 @@ function isRevenueHourlyGroupBy(groupBy: AnalyticsGroupByPreset): boolean {
|
||||
return groupBy === '1h' || groupBy === '6h'
|
||||
}
|
||||
|
||||
function getAllTimeYearGroupStart(end: Date): Date {
|
||||
const start = new Date(end)
|
||||
start.setFullYear(2021)
|
||||
return start
|
||||
}
|
||||
|
||||
const groupByOptions = computed<ComboboxOption<AnalyticsGroupByPreset>[]>(() => {
|
||||
const timeframeMinutes = selectedTimeframeDurationMinutes.value
|
||||
const options = groupByPresetOptions.map((option) => {
|
||||
@@ -1159,13 +1153,7 @@ function buildMetricFilters(
|
||||
|
||||
const fetchRequest = computed<Labrinth.Analytics.v3.FetchRequest>(() => {
|
||||
const rawRange = selectedTimeRange.value
|
||||
const rawStart =
|
||||
selectedTimeframeMode.value === 'preset' &&
|
||||
selectedTimeframe.value === 'all_time' &&
|
||||
selectedGroupBy.value === 'year'
|
||||
? getAllTimeYearGroupStart(rawRange.end)
|
||||
: rawRange.start
|
||||
const { start, end } = ensureMinimumTimeRange(rawStart, rawRange.end)
|
||||
const { start, end } = ensureMinimumTimeRange(rawRange.start, rawRange.end)
|
||||
|
||||
const groupByMs = getAnalyticsGroupByPresetMinutes(selectedGroupBy.value) * 60 * 1000
|
||||
const desiredSlices = Math.max(1, Math.floor((end.getTime() - start.getTime()) / groupByMs))
|
||||
|
||||
@@ -84,6 +84,7 @@ function subtractCalendarMonths(date: Date, months: number): Date {
|
||||
export function getTimeRangeForPreset(
|
||||
preset: AnalyticsTimeframePreset,
|
||||
nowTimestamp: number,
|
||||
allTimeStartDate: Date = new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
|
||||
): AnalyticsTimeRange {
|
||||
const now = getRoundedNow(nowTimestamp)
|
||||
const end = new Date(now)
|
||||
@@ -130,7 +131,7 @@ export function getTimeRangeForPreset(
|
||||
}
|
||||
case 'all_time':
|
||||
return {
|
||||
start: new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
|
||||
start: new Date(allTimeStartDate),
|
||||
end,
|
||||
}
|
||||
default:
|
||||
@@ -193,6 +194,7 @@ export function getAnalyticsTimeRange({
|
||||
customStartDate,
|
||||
customEndDate,
|
||||
nowTimestamp,
|
||||
allTimeStartDate,
|
||||
}: {
|
||||
mode: AnalyticsTimeframeMode
|
||||
preset: AnalyticsTimeframePreset
|
||||
@@ -201,6 +203,7 @@ export function getAnalyticsTimeRange({
|
||||
customStartDate: string
|
||||
customEndDate: string
|
||||
nowTimestamp: number
|
||||
allTimeStartDate?: Date
|
||||
}): AnalyticsTimeRange {
|
||||
switch (mode) {
|
||||
case 'last':
|
||||
@@ -211,7 +214,7 @@ export function getAnalyticsTimeRange({
|
||||
return getTimeRangeForCustomDateTimeRange(customStartDate, customEndDate)
|
||||
case 'preset':
|
||||
default:
|
||||
return getTimeRangeForPreset(preset, nowTimestamp)
|
||||
return getTimeRangeForPreset(preset, nowTimestamp, allTimeStartDate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +272,7 @@ export function useSelectedAnalyticsTimeRange() {
|
||||
selectedCustomTimeframeStartDate,
|
||||
selectedCustomTimeframeEndDate,
|
||||
queryRefreshTimestamp,
|
||||
analyticsAllTimeStartDate,
|
||||
} = injectAnalyticsDashboardContext()
|
||||
|
||||
const selectedTimeRange = computed(() =>
|
||||
@@ -280,6 +284,7 @@ export function useSelectedAnalyticsTimeRange() {
|
||||
customStartDate: selectedCustomTimeframeStartDate.value,
|
||||
customEndDate: selectedCustomTimeframeEndDate.value,
|
||||
nowTimestamp: queryRefreshTimestamp.value,
|
||||
allTimeStartDate: analyticsAllTimeStartDate.value,
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user