Skip to content

Commit f240c15

Browse files
authored
Merge branch 'master' into aknaus/feat/laravel-insights/redirect-feedback
2 parents 0463b37 + 7cd19d7 commit f240c15

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

static/app/views/insights/pages/backend/laravel/cachesWidget.tsx

+31-21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Link from 'sentry/components/links/link';
66
import {getChartColorPalette} from 'sentry/constants/chartPalette';
77
import {IconExpand} from 'sentry/icons';
88
import {t} from 'sentry/locale';
9+
import {formatAbbreviatedNumber} from 'sentry/utils/formatters';
910
import {useApiQuery} from 'sentry/utils/queryClient';
1011
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
1112
import useOrganization from 'sentry/utils/useOrganization';
@@ -31,6 +32,7 @@ export function CachesWidget({query}: {query?: string}) {
3132
const cachesRequest = useApiQuery<{
3233
data: Array<{
3334
'cache_miss_rate()': number;
35+
'count()': number;
3436
'project.id': string;
3537
transaction: string;
3638
}>;
@@ -41,7 +43,7 @@ export function CachesWidget({query}: {query?: string}) {
4143
query: {
4244
...pageFilterChartParams,
4345
dataset: 'spansMetrics',
44-
field: ['transaction', 'project.id', 'cache_miss_rate()'],
46+
field: ['transaction', 'project.id', 'cache_miss_rate()', 'count()'],
4547
query: `span.op:[cache.get_item,cache.get] ${query}`,
4648
sort: '-cache_miss_rate()',
4749
per_page: 4,
@@ -117,26 +119,34 @@ export function CachesWidget({query}: {query?: string}) {
117119
);
118120

119121
const footer = hasData && (
120-
<WidgetFooterTable>
121-
{cachesRequest.data?.data.map((item, index) => (
122-
<Fragment key={item.transaction}>
123-
<div>
124-
<SeriesColorIndicator
125-
style={{
126-
backgroundColor: colorPalette[index],
127-
}}
128-
/>
129-
</div>
130-
<div>
131-
<Link
132-
to={`/insights/backend/caches?project=${item['project.id']}&transaction=${item.transaction}`}
133-
>
134-
{item.transaction}
135-
</Link>
136-
</div>
137-
<span>{(item['cache_miss_rate()'] * 100).toFixed(2)}%</span>
138-
</Fragment>
139-
))}
122+
<WidgetFooterTable columns={4}>
123+
{cachesRequest.data?.data.map((item, index) => {
124+
const count = item['count()'];
125+
const cacheMissRate = item['cache_miss_rate()'];
126+
const missedCount = Math.floor(count * cacheMissRate);
127+
return (
128+
<Fragment key={item.transaction}>
129+
<div>
130+
<SeriesColorIndicator
131+
style={{
132+
backgroundColor: colorPalette[index],
133+
}}
134+
/>
135+
</div>
136+
<div>
137+
<Link
138+
to={`/insights/backend/caches?project=${item['project.id']}&transaction=${item.transaction}`}
139+
>
140+
{item.transaction}
141+
</Link>
142+
</div>
143+
<span>
144+
{formatAbbreviatedNumber(missedCount)} / {formatAbbreviatedNumber(count)}
145+
</span>
146+
<span>{(cacheMissRate * 100).toFixed(2)}%</span>
147+
</Fragment>
148+
);
149+
})}
140150
</WidgetFooterTable>
141151
);
142152

static/app/views/insights/pages/backend/laravel/styles.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,38 @@ export const ModalTableWrapper = styled(Panel)`
1111
margin-top: ${space(2)};
1212
`;
1313

14-
export const WidgetFooterTable = styled('div')`
14+
const getColumns = (props: {columns?: number}) => {
15+
return props.columns || 3;
16+
};
17+
18+
export const WidgetFooterTable = styled('div')<{columns?: number}>`
1519
display: grid;
16-
grid-template-columns: max-content 1fr max-content;
20+
grid-template-columns: max-content 1fr repeat(${p => getColumns(p) - 2}, max-content);
1721
font-size: ${p => p.theme.fontSizeSmall};
1822
1923
& > * {
2024
padding: ${space(1)} ${space(0.5)};
25+
text-align: right;
2126
}
2227
23-
& > *:nth-child(3n + 1) {
28+
& > *:nth-child(${p => getColumns(p)}n + 1) {
2429
position: relative;
30+
text-align: left;
2531
}
2632
27-
& > *:nth-child(3n + 2) {
33+
& > *:nth-child(${p => getColumns(p)}n + 2) {
2834
${p => p.theme.overflowEllipsis};
2935
padding-left: ${space(1.5)};
3036
min-width: 0px;
37+
text-align: left;
3138
}
3239
33-
& > *:nth-child(3n) {
40+
& > *:nth-child(${p => getColumns(p)}n) {
3441
padding-right: ${space(2)};
3542
text-align: right;
3643
}
3744
38-
& > *:not(:nth-last-child(-n + 3)) {
45+
& > *:not(:nth-last-child(-n + ${p => getColumns(p)})) {
3946
border-bottom: 1px solid ${p => p.theme.border};
4047
}
4148
`;

0 commit comments

Comments
 (0)