mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
update avg aggregate for revenue report
This commit is contained in:
parent
9d0da45c09
commit
065499a3fa
@ -55,35 +55,35 @@ export function TestConsole({ websiteId }: { websiteId: string }) {
|
||||
referrer: 'https://www.google.com',
|
||||
}));
|
||||
window['umami'].track('checkout-cart', {
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
currency: 'SHIBA',
|
||||
revenue: parseFloat((Math.random() * 1000).toFixed(2)),
|
||||
currency: 'USD',
|
||||
});
|
||||
window['umami'].track('affiliate-link', {
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
currency: 'ETH',
|
||||
revenue: parseFloat((Math.random() * 1000).toFixed(2)),
|
||||
currency: 'USD',
|
||||
});
|
||||
window['umami'].track('promotion-link', {
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
revenue: parseFloat((Math.random() * 1000).toFixed(2)),
|
||||
currency: 'USD',
|
||||
});
|
||||
window['umami'].track('checkout-cart', {
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
revenue: parseFloat((Math.random() * 1000).toFixed(2)),
|
||||
currency: 'EUR',
|
||||
});
|
||||
window['umami'].track('promotion-link', {
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
revenue: parseFloat((Math.random() * 1000).toFixed(2)),
|
||||
currency: 'EUR',
|
||||
});
|
||||
window['umami'].track('affiliate-link', {
|
||||
item1: {
|
||||
productIdentity: 'ABC424',
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
currency: 'MXN',
|
||||
revenue: parseFloat((Math.random() * 10000).toFixed(2)),
|
||||
currency: 'JPY',
|
||||
},
|
||||
item2: {
|
||||
productIdentity: 'ZYW684',
|
||||
revenue: parseFloat((Math.random() * 100000).toFixed(2)),
|
||||
currency: 'MXN',
|
||||
revenue: parseFloat((Math.random() * 10000).toFixed(2)),
|
||||
currency: 'JPY',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export function RevenueTable() {
|
||||
{row => formatLongCurrency(row.sum, row.currency)}
|
||||
</GridColumn>
|
||||
<GridColumn name="currency" label={formatMessage(labels.average)} alignment="end">
|
||||
{row => formatLongCurrency(row.avg, row.currency)}
|
||||
{row => formatLongCurrency(row.count ? row.sum / row.count : 0, row.currency)}
|
||||
</GridColumn>
|
||||
<GridColumn name="currency" label={formatMessage(labels.transactions)} alignment="end">
|
||||
{row => row.count}
|
||||
|
@ -87,7 +87,7 @@ export function RevenueView({ isLoading }: RevenueViewProps) {
|
||||
const metricData = useMemo(() => {
|
||||
if (!data) return [];
|
||||
|
||||
const { sum, avg, count, unique_count } = data.total;
|
||||
const { sum, count, unique_count } = data.total;
|
||||
|
||||
return [
|
||||
{
|
||||
@ -96,7 +96,7 @@ export function RevenueView({ isLoading }: RevenueViewProps) {
|
||||
formatValue: n => formatLongCurrency(n, currency),
|
||||
},
|
||||
{
|
||||
value: avg,
|
||||
value: count ? sum / count : 0,
|
||||
label: formatMessage(labels.average),
|
||||
formatValue: n => formatLongCurrency(n, currency),
|
||||
},
|
||||
|
@ -114,5 +114,5 @@ export function formatLongCurrency(value: number, currency: string, locale = 'en
|
||||
return `${formatCurrency(n / 1000, currency, locale)}k`;
|
||||
}
|
||||
|
||||
return formatCurrency(n / 1000, currency, locale);
|
||||
return formatCurrency(n, currency, locale);
|
||||
}
|
||||
|
@ -32,11 +32,10 @@ async function relationalQuery(
|
||||
): Promise<{
|
||||
chart: { x: string; t: string; y: number }[];
|
||||
country: { name: string; value: number }[];
|
||||
total: { sum: number; avg: number; count: number; unique_count: number };
|
||||
total: { sum: number; count: number; unique_count: number };
|
||||
table: {
|
||||
currency: string;
|
||||
sum: number;
|
||||
avg: number;
|
||||
count: number;
|
||||
unique_count: number;
|
||||
}[];
|
||||
@ -96,7 +95,6 @@ async function relationalQuery(
|
||||
`
|
||||
select
|
||||
sum(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as sum,
|
||||
avg(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as avg,
|
||||
count(distinct event_id) as count,
|
||||
count(distinct session_id) as unique_count
|
||||
from event_data ed
|
||||
@ -119,7 +117,6 @@ async function relationalQuery(
|
||||
select
|
||||
c.currency,
|
||||
sum(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as sum,
|
||||
avg(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as avg,
|
||||
count(distinct ed.website_event_id) as count,
|
||||
count(distinct we.session_id) as unique_count
|
||||
from event_data ed
|
||||
@ -153,11 +150,10 @@ async function clickhouseQuery(
|
||||
): Promise<{
|
||||
chart: { x: string; t: string; y: number }[];
|
||||
country: { name: string; value: number }[];
|
||||
total: { sum: number; avg: number; count: number; unique_count: number };
|
||||
total: { sum: number; count: number; unique_count: number };
|
||||
table: {
|
||||
currency: string;
|
||||
sum: number;
|
||||
avg: number;
|
||||
count: number;
|
||||
unique_count: number;
|
||||
}[];
|
||||
@ -230,7 +226,6 @@ async function clickhouseQuery(
|
||||
`
|
||||
select
|
||||
sum(coalesce(toDecimal64(number_value, 2), toDecimal64(string_value, 2))) as sum,
|
||||
avg(coalesce(toDecimal64(number_value, 2), toDecimal64(string_value, 2))) as avg,
|
||||
uniqExact(event_id) as count,
|
||||
uniqExact(session_id) as unique_count
|
||||
from event_data
|
||||
@ -259,7 +254,6 @@ async function clickhouseQuery(
|
||||
select
|
||||
c.currency,
|
||||
sum(coalesce(toDecimal64(ed.number_value, 2), toDecimal64(ed.string_value, 2))) as sum,
|
||||
avg(coalesce(toDecimal64(ed.number_value, 2), toDecimal64(ed.string_value, 2))) as avg,
|
||||
uniqExact(ed.event_id) as count,
|
||||
uniqExact(ed.session_id) as unique_count
|
||||
from event_data ed
|
||||
|
Loading…
x
Reference in New Issue
Block a user