change views back to pageviews

This commit is contained in:
Francis Cao 2024-03-27 11:17:00 -07:00
parent d945ed3a23
commit ab58c76b6a
3 changed files with 16 additions and 15 deletions

View File

@ -78,7 +78,6 @@ FROM umami.website_event we
JOIN umami.website_event_join j
ON we.session_id = j.session_id
and date_trunc('hour', we.created_at) = j.created_at
WHERE we.created_at > '2023-03-31';
RENAME TABLE umami.website_event TO umami.website_event_old;
RENAME TABLE umami.website_event_new TO umami.website_event;

View File

@ -21,10 +21,10 @@ export function WebsiteMetricsBar({
const { ref, isSticky } = useSticky({ enabled: sticky });
const { data, isLoading, isFetched, error } = useWebsiteStats(websiteId);
const { views, visitors, visits, bounces, totaltime } = data || {};
const { pageviews, visitors, visits, bounces, totaltime } = data || {};
const num = Math.min(data && visitors.value, data && bounces.value);
const diffs = data && {
views: views.value - views.change,
pageviews: pageviews.value - pageviews.change,
visitors: visitors.value - visitors.change,
visits: visits.value - visits.change,
bounces: bounces.value - bounces.change,
@ -40,12 +40,12 @@ export function WebsiteMetricsBar({
})}
>
<MetricsBar isLoading={isLoading} isFetched={isFetched} error={error}>
{views && visitors && (
{pageviews && visitors && (
<>
<MetricCard
label={formatMessage(labels.views)}
value={views.value}
change={views.change}
label={formatMessage(labels.pageviews)}
value={pageviews.value}
change={pageviews.change}
/>
<MetricCard
label={formatMessage(labels.visits)}
@ -72,12 +72,14 @@ export function WebsiteMetricsBar({
<MetricCard
label={formatMessage(labels.averageVisitTime)}
value={
totaltime.value && views.value ? totaltime.value / (views.value - bounces.value) : 0
totaltime.value && pageviews.value
? totaltime.value / (pageviews.value - bounces.value)
: 0
}
change={
totaltime.value && views.value
? (diffs.totaltime / (diffs.views - diffs.bounces) -
totaltime.value / (views.value - bounces.value)) *
totaltime.value && pageviews.value
? (diffs.totaltime / (diffs.pageviews - diffs.bounces) -
totaltime.value / (pageviews.value - bounces.value)) *
-1 || 0
: 0
}

View File

@ -7,7 +7,7 @@ import { QueryFilters } from 'lib/types';
export async function getWebsiteStats(
...args: [websiteId: string, filters: QueryFilters]
): Promise<
{ views: number; visitors: number; visits: number; bounces: number; totaltime: number }[]
{ pageviews: number; visitors: number; visits: number; bounces: number; totaltime: number }[]
> {
return runQuery({
[PRISMA]: () => relationalQuery(...args),
@ -19,7 +19,7 @@ async function relationalQuery(
websiteId: string,
filters: QueryFilters,
): Promise<
{ views: number; visitors: number; visits: number; bounces: number; totaltime: number }[]
{ pageviews: number; visitors: number; visits: number; bounces: number; totaltime: number }[]
> {
const { getTimestampDiffQuery, parseFilters, rawQuery } = prisma;
const { filterQuery, joinSession, params } = await parseFilters(websiteId, {
@ -61,7 +61,7 @@ async function clickhouseQuery(
websiteId: string,
filters: QueryFilters,
): Promise<
{ views: number; visitors: number; visits: number; bounces: number; totaltime: number }[]
{ pageviews: number; visitors: number; visits: number; bounces: number; totaltime: number }[]
> {
const { rawQuery, parseFilters } = clickhouse;
const { filterQuery, params } = await parseFilters(websiteId, {
@ -96,7 +96,7 @@ async function clickhouseQuery(
).then(a => {
return Object.values(a).map(a => {
return {
views: Number(a.views),
pageviews: Number(a.views),
visitors: Number(a.visitors),
visits: Number(a.visits),
bounces: Number(a.bounces),