Skip to content
Draft
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
11 changes: 6 additions & 5 deletions static/app/views/organizationStats/mapSeriesToChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ export function mapSeriesToChart({
// to get the `accepted_stored` count
if (category === 'span_indexed') {
if (outcome === Outcome.ACCEPTED) {
countAcceptedStored += group.totals['sum(quantity)']!;
countAcceptedStored += group.totals?.['sum(quantity)'] ?? 0;
}
} else {
if (outcome !== Outcome.CLIENT_DISCARD) {
count.total += group.totals['sum(quantity)']!;
count.total += group.totals?.['sum(quantity)'] ?? 0;
}
(count as any)[outcome!] += group.totals['sum(quantity)']!;
(count as any)[outcome!] += group.totals?.['sum(quantity)'] ?? 0;
}

if (category === 'span_indexed' && outcome !== Outcome.ACCEPTED) {
// we need `span_indexed` data for `accepted_stored` only
return;
}

group.series['sum(quantity)']!.forEach((stat, i) => {
(group.series?.['sum(quantity)'] ?? []).forEach((stat, i) => {
const dataObject = {name: orgStats.intervals[i]!, value: stat};

const strigfiedReason = String(group.by.reason ?? '');
Expand All @@ -135,7 +135,8 @@ export function mapSeriesToChart({

if (existingSubLabel) {
// Check if the existing sub-label's data length matches the intervals length
if (existingSubLabel.data.length === group.series['sum(quantity)']!.length) {
const seriesLength = group.series?.['sum(quantity)']?.length ?? 0;
if (existingSubLabel.data.length === seriesLength) {
// Update the value of the current interval
existingSubLabel.data[i]!.value += stat;
} else {
Expand Down
8 changes: 4 additions & 4 deletions static/app/views/organizationStats/usageStatsProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ export function UsageStatsProjects({
}

if (outcome !== Outcome.CLIENT_DISCARD && category !== 'span_indexed') {
stats[projectId!]!.total += group.totals['sum(quantity)']!;
stats[projectId!]!.total += group.totals?.['sum(quantity)'] ?? 0;
}

if (category === 'span_indexed' && outcome === Outcome.ACCEPTED) {
stats[projectId!]!.accepted_stored += group.totals['sum(quantity)']!;
stats[projectId!]!.accepted_stored += group.totals?.['sum(quantity)'] ?? 0;
return;
}

Expand All @@ -299,15 +299,15 @@ export function UsageStatsProjects({
outcome === Outcome.FILTERED ||
outcome === Outcome.INVALID
) {
stats[projectId!]![outcome] += group.totals['sum(quantity)']!;
stats[projectId!]![outcome] += group.totals?.['sum(quantity)'] ?? 0;
}

if (
outcome === Outcome.RATE_LIMITED ||
outcome === Outcome.CARDINALITY_LIMITED ||
outcome === Outcome.ABUSE
) {
stats[projectId!]![SortBy.RATE_LIMITED] += group.totals['sum(quantity)']!;
stats[projectId!]![SortBy.RATE_LIMITED] += group.totals?.['sum(quantity)'] ?? 0;
}
});

Expand Down
Loading