From c5589b21627ecdc7eb1d379694e50c36f1fb527b Mon Sep 17 00:00:00 2001 From: Ben Vinegar <2153+benvinegar@users.noreply.github.com> Date: Mon, 1 Apr 2024 11:52:37 -0400 Subject: [PATCH] Fix tests, lint errors --- app/analytics/query.ts | 5 ++-- app/routes/dashboard.test.tsx | 52 ++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/app/analytics/query.ts b/app/analytics/query.ts index c0296e52..1868d28d 100644 --- a/app/analytics/query.ts +++ b/app/analytics/query.ts @@ -199,6 +199,7 @@ export class AnalyticsEngineAPI { // like double1 (isVisitor) or double2 (isSession/isVisit). This // is just a limitation of Cloudflare Analytics Engine. // -- but you can filter on them (using WHERE) + const query = ` SELECT SUM(_sample_interval) as count, @@ -264,7 +265,7 @@ export class AnalyticsEngineAPI { // defaults to 1 day if not specified const siteIdColumn = ColumnMappings["siteId"]; - let intervalSql = intervalToSql(interval, tz); + const intervalSql = intervalToSql(interval, tz); const query = ` SELECT SUM(_sample_interval) as count, @@ -493,7 +494,7 @@ export class AnalyticsEngineAPI { limit = limit || 10; - let intervalSql = intervalToSql(interval, tz); + const intervalSql = intervalToSql(interval, tz); const query = ` SELECT SUM(_sample_interval) as count, diff --git a/app/routes/dashboard.test.tsx b/app/routes/dashboard.test.tsx index e63b95e1..1538929e 100644 --- a/app/routes/dashboard.test.tsx +++ b/app/routes/dashboard.test.tsx @@ -178,7 +178,7 @@ describe("Dashboard route", () => { // response for getViewsGroupedByInterval fetch.mockResolvedValueOnce( createFetchResponse({ - data: [{ bucket: "2024-01-11 00:00:00", count: 4 }], + data: [{ bucket: "2024-01-11 05:00:00", count: 4 }], }), ); @@ -212,16 +212,17 @@ describe("Dashboard route", () => { countByBrowser: [["Chrome", 2]], countByDevice: [["Desktop", 3]], viewsGroupedByInterval: [ - ["2024-01-11 00:00:00", 4], - ["2024-01-12 00:00:00", 0], - ["2024-01-13 00:00:00", 0], - ["2024-01-14 00:00:00", 0], - ["2024-01-15 00:00:00", 0], - ["2024-01-16 00:00:00", 0], - ["2024-01-17 00:00:00", 0], - ["2024-01-18 00:00:00", 0], + ["2024-01-11 05:00:00", 4], + ["2024-01-12 05:00:00", 0], + ["2024-01-13 05:00:00", 0], + ["2024-01-14 05:00:00", 0], + ["2024-01-15 05:00:00", 0], + ["2024-01-16 05:00:00", 0], + ["2024-01-17 05:00:00", 0], + ["2024-01-18 05:00:00", 0], ], intervalType: "DAY", + interval: "7d", }); }); @@ -265,16 +266,17 @@ describe("Dashboard route", () => { countByBrowser: [], countByDevice: [], viewsGroupedByInterval: [ - ["2024-01-11 00:00:00", 0], - ["2024-01-12 00:00:00", 0], - ["2024-01-13 00:00:00", 0], - ["2024-01-14 00:00:00", 0], - ["2024-01-15 00:00:00", 0], - ["2024-01-16 00:00:00", 0], - ["2024-01-17 00:00:00", 0], - ["2024-01-18 00:00:00", 0], + ["2024-01-11 05:00:00", 0], + ["2024-01-12 05:00:00", 0], + ["2024-01-13 05:00:00", 0], + ["2024-01-14 05:00:00", 0], + ["2024-01-15 05:00:00", 0], + ["2024-01-16 05:00:00", 0], + ["2024-01-17 05:00:00", 0], + ["2024-01-18 05:00:00", 0], ], intervalType: "DAY", + interval: "7d", }); }); }); @@ -344,14 +346,14 @@ describe("Dashboard route", () => { ["Tablet", 60], ], viewsGroupedByInterval: [ - ["2024-01-11 00:00:00", 0], - ["2024-01-12 00:00:00", 0], - ["2024-01-13 00:00:00", 3], - ["2024-01-14 00:00:00", 0], - ["2024-01-15 00:00:00", 0], - ["2024-01-16 00:00:00", 2], - ["2024-01-17 00:00:00", 1], - ["2024-01-18 00:00:00", 0], + ["2024-01-11 05:00:00", 0], + ["2024-01-12 05:00:00", 0], + ["2024-01-13 05:00:00", 3], + ["2024-01-14 05:00:00", 0], + ["2024-01-15 05:00:00", 0], + ["2024-01-16 05:00:00", 2], + ["2024-01-17 05:00:00", 1], + ["2024-01-18 05:00:00", 0], ], intervalType: "day", };