Skip to content

Commit 8f1ba5d

Browse files
ultracite[bot]Ultracite
andauthored
fix: Auto-fix lint issues (#254)
Automatically fixed by Ultracite Co-authored-by: Ultracite <[email protected]>
1 parent c4dd69f commit 8f1ba5d

File tree

9 files changed

+188
-182
lines changed

9 files changed

+188
-182
lines changed

apps/dashboard/app/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ import { redirect } from "next/navigation";
33
export default function Home() {
44
redirect("/websites");
55
}
6-

apps/dashboard/hooks/use-global-analytics.ts

Lines changed: 118 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -5,116 +5,125 @@ import { useMemo } from "react";
55
import { useWebsites } from "./use-websites";
66

77
export interface GlobalAnalytics {
8-
totalActiveUsers: number;
9-
totalViews: number;
10-
averageTrend: number;
11-
trendDirection: "up" | "down" | "neutral";
12-
websiteCount: number;
13-
topPerformers: Array<{
14-
id: string;
15-
name: string | null;
16-
domain: string;
17-
views: number;
18-
trend: ProcessedMiniChartData["trend"];
19-
activeUsers: number;
20-
}>;
21-
needsSetup: Array<{
22-
id: string;
23-
name: string | null;
24-
domain: string;
25-
}>;
8+
totalActiveUsers: number;
9+
totalViews: number;
10+
averageTrend: number;
11+
trendDirection: "up" | "down" | "neutral";
12+
websiteCount: number;
13+
topPerformers: Array<{
14+
id: string;
15+
name: string | null;
16+
domain: string;
17+
views: number;
18+
trend: ProcessedMiniChartData["trend"];
19+
activeUsers: number;
20+
}>;
21+
needsSetup: Array<{
22+
id: string;
23+
name: string | null;
24+
domain: string;
25+
}>;
2626
}
2727

2828
export function useGlobalAnalytics() {
29-
const { websites, chartData, activeUsers, isLoading, isFetching, isError, refetch } =
30-
useWebsites();
31-
32-
const analytics = useMemo<GlobalAnalytics>(() => {
33-
if (!websites || websites.length === 0) {
34-
return {
35-
totalActiveUsers: 0,
36-
totalViews: 0,
37-
averageTrend: 0,
38-
trendDirection: "neutral",
39-
websiteCount: 0,
40-
topPerformers: [],
41-
needsSetup: [],
42-
};
43-
}
44-
45-
let totalActiveUsers = 0;
46-
let totalViews = 0;
47-
let trendSum = 0;
48-
let trendCount = 0;
49-
50-
const websiteStats: GlobalAnalytics["topPerformers"] = [];
51-
const needsSetup: GlobalAnalytics["needsSetup"] = [];
52-
53-
for (const website of websites) {
54-
const chart = chartData?.[website.id];
55-
const active = activeUsers?.[website.id] ?? 0;
56-
57-
totalActiveUsers += active;
58-
59-
if (chart) {
60-
totalViews += chart.totalViews;
61-
62-
if (chart.trend) {
63-
const trendValue = chart.trend.type === "down" ? -chart.trend.value : chart.trend.value;
64-
trendSum += trendValue;
65-
trendCount++;
66-
}
67-
68-
if (chart.totalViews > 0) {
69-
websiteStats.push({
70-
id: website.id,
71-
name: website.name,
72-
domain: website.domain,
73-
views: chart.totalViews,
74-
trend: chart.trend,
75-
activeUsers: active,
76-
});
77-
} else {
78-
needsSetup.push({
79-
id: website.id,
80-
name: website.name,
81-
domain: website.domain,
82-
});
83-
}
84-
} else {
85-
needsSetup.push({
86-
id: website.id,
87-
name: website.name,
88-
domain: website.domain,
89-
});
90-
}
91-
}
92-
93-
const averageTrend = trendCount > 0 ? trendSum / trendCount : 0;
94-
const trendDirection: GlobalAnalytics["trendDirection"] =
95-
averageTrend > 1 ? "up" : averageTrend < -1 ? "down" : "neutral";
96-
97-
const topPerformers = websiteStats
98-
.sort((a, b) => b.views - a.views)
99-
.slice(0, 5);
100-
101-
return {
102-
totalActiveUsers,
103-
totalViews,
104-
averageTrend: Math.abs(averageTrend),
105-
trendDirection,
106-
websiteCount: websites.length,
107-
topPerformers,
108-
needsSetup,
109-
};
110-
}, [websites, chartData, activeUsers]);
111-
112-
return {
113-
...analytics,
114-
isLoading,
115-
isFetching,
116-
isError,
117-
refetch,
118-
};
29+
const {
30+
websites,
31+
chartData,
32+
activeUsers,
33+
isLoading,
34+
isFetching,
35+
isError,
36+
refetch,
37+
} = useWebsites();
38+
39+
const analytics = useMemo<GlobalAnalytics>(() => {
40+
if (!websites || websites.length === 0) {
41+
return {
42+
totalActiveUsers: 0,
43+
totalViews: 0,
44+
averageTrend: 0,
45+
trendDirection: "neutral",
46+
websiteCount: 0,
47+
topPerformers: [],
48+
needsSetup: [],
49+
};
50+
}
51+
52+
let totalActiveUsers = 0;
53+
let totalViews = 0;
54+
let trendSum = 0;
55+
let trendCount = 0;
56+
57+
const websiteStats: GlobalAnalytics["topPerformers"] = [];
58+
const needsSetup: GlobalAnalytics["needsSetup"] = [];
59+
60+
for (const website of websites) {
61+
const chart = chartData?.[website.id];
62+
const active = activeUsers?.[website.id] ?? 0;
63+
64+
totalActiveUsers += active;
65+
66+
if (chart) {
67+
totalViews += chart.totalViews;
68+
69+
if (chart.trend) {
70+
const trendValue =
71+
chart.trend.type === "down"
72+
? -chart.trend.value
73+
: chart.trend.value;
74+
trendSum += trendValue;
75+
trendCount++;
76+
}
77+
78+
if (chart.totalViews > 0) {
79+
websiteStats.push({
80+
id: website.id,
81+
name: website.name,
82+
domain: website.domain,
83+
views: chart.totalViews,
84+
trend: chart.trend,
85+
activeUsers: active,
86+
});
87+
} else {
88+
needsSetup.push({
89+
id: website.id,
90+
name: website.name,
91+
domain: website.domain,
92+
});
93+
}
94+
} else {
95+
needsSetup.push({
96+
id: website.id,
97+
name: website.name,
98+
domain: website.domain,
99+
});
100+
}
101+
}
102+
103+
const averageTrend = trendCount > 0 ? trendSum / trendCount : 0;
104+
const trendDirection: GlobalAnalytics["trendDirection"] =
105+
averageTrend > 1 ? "up" : averageTrend < -1 ? "down" : "neutral";
106+
107+
const topPerformers = websiteStats
108+
.sort((a, b) => b.views - a.views)
109+
.slice(0, 5);
110+
111+
return {
112+
totalActiveUsers,
113+
totalViews,
114+
averageTrend: Math.abs(averageTrend),
115+
trendDirection,
116+
websiteCount: websites.length,
117+
topPerformers,
118+
needsSetup,
119+
};
120+
}, [websites, chartData, activeUsers]);
121+
122+
return {
123+
...analytics,
124+
isLoading,
125+
isFetching,
126+
isError,
127+
refetch,
128+
};
119129
}
120-

apps/dashboard/hooks/use-pulse-status.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,57 @@ import { useMemo } from "react";
55
import { orpc } from "@/lib/orpc";
66

77
export interface PulseStatus {
8-
totalMonitors: number;
9-
activeMonitors: number;
10-
pausedMonitors: number;
11-
healthPercentage: number;
12-
monitors: Array<{
13-
id: string;
14-
name: string | null;
15-
url: string;
16-
websiteId: string | null;
17-
isPaused: boolean;
18-
granularity: string;
19-
}>;
8+
totalMonitors: number;
9+
activeMonitors: number;
10+
pausedMonitors: number;
11+
healthPercentage: number;
12+
monitors: Array<{
13+
id: string;
14+
name: string | null;
15+
url: string;
16+
websiteId: string | null;
17+
isPaused: boolean;
18+
granularity: string;
19+
}>;
2020
}
2121

2222
export function usePulseStatus() {
23-
const query = useQuery({
24-
...orpc.uptime.listSchedules.queryOptions({
25-
input: {},
26-
}),
27-
});
28-
29-
const status = useMemo<PulseStatus>(() => {
30-
const schedules = query.data ?? [];
31-
32-
const activeMonitors = schedules.filter((s) => !s.isPaused).length;
33-
const pausedMonitors = schedules.filter((s) => s.isPaused).length;
34-
const totalMonitors = schedules.length;
35-
const healthPercentage = totalMonitors > 0 ? (activeMonitors / totalMonitors) * 100 : 100;
36-
37-
return {
38-
totalMonitors,
39-
activeMonitors,
40-
pausedMonitors,
41-
healthPercentage,
42-
monitors: schedules.map((s) => ({
43-
id: s.id,
44-
name: s.name,
45-
url: s.url,
46-
websiteId: s.websiteId,
47-
isPaused: s.isPaused,
48-
granularity: s.granularity,
49-
})),
50-
};
51-
}, [query.data]);
52-
53-
return {
54-
...status,
55-
isLoading: query.isLoading,
56-
isFetching: query.isFetching,
57-
isError: query.isError,
58-
refetch: query.refetch,
59-
};
23+
const query = useQuery({
24+
...orpc.uptime.listSchedules.queryOptions({
25+
input: {},
26+
}),
27+
});
28+
29+
const status = useMemo<PulseStatus>(() => {
30+
const schedules = query.data ?? [];
31+
32+
const activeMonitors = schedules.filter((s) => !s.isPaused).length;
33+
const pausedMonitors = schedules.filter((s) => s.isPaused).length;
34+
const totalMonitors = schedules.length;
35+
const healthPercentage =
36+
totalMonitors > 0 ? (activeMonitors / totalMonitors) * 100 : 100;
37+
38+
return {
39+
totalMonitors,
40+
activeMonitors,
41+
pausedMonitors,
42+
healthPercentage,
43+
monitors: schedules.map((s) => ({
44+
id: s.id,
45+
name: s.name,
46+
url: s.url,
47+
websiteId: s.websiteId,
48+
isPaused: s.isPaused,
49+
granularity: s.granularity,
50+
})),
51+
};
52+
}, [query.data]);
53+
54+
return {
55+
...status,
56+
isLoading: query.isLoading,
57+
isFetching: query.isFetching,
58+
isError: query.isError,
59+
refetch: query.refetch,
60+
};
6061
}
61-

apps/dashboard/stores/jotai/filterAtoms.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import dayjs from "dayjs";
33
export interface DynamicQueryFilter {
44
field: string;
55
operator:
6-
| "eq"
7-
| "ne"
8-
| "contains"
9-
| "not_contains"
10-
| "starts_with"
11-
| "in"
12-
| "not_in";
6+
| "eq"
7+
| "ne"
8+
| "contains"
9+
| "not_contains"
10+
| "starts_with"
11+
| "in"
12+
| "not_in";
1313
value: string | number | (string | number)[];
1414
}
1515

apps/docs/lib/sitemap-generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ export async function generateSitemapEntries(): Promise<MetadataRoute.Sitemap> {
129129
const latestPostDate =
130130
blogEntries.length > 0
131131
? blogEntries.reduce(
132-
(latest, entry) =>
133-
entry.lastModified > latest ? entry.lastModified : latest,
134-
blogEntries[0].lastModified
135-
)
132+
(latest, entry) =>
133+
entry.lastModified > latest ? entry.lastModified : latest,
134+
blogEntries[0].lastModified
135+
)
136136
: lastModified;
137137

138138
entries.push({

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)