From 6a10e6bf08f4db2dcb17260f0c51dd048fe07d21 Mon Sep 17 00:00:00 2001 From: Mitch Downey Date: Sun, 3 Dec 2023 15:31:46 -0600 Subject: [PATCH 1/2] Fix query unique pageview stats script --- src/services/stats.ts | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/services/stats.ts b/src/services/stats.ts index 988d4f58..d7daafed 100644 --- a/src/services/stats.ts +++ b/src/services/stats.ts @@ -10,10 +10,10 @@ enum PagePaths { clips = 'clip', episodes = 'episode', podcasts = 'podcast', - albums = 'albums', - tracks = 'tracks', - channels = 'channels', - videos = 'videos' + albums = 'album', + tracks = 'track', + channels = 'channel', + videos = 'video' } enum StartDateOffset { @@ -27,7 +27,11 @@ enum StartDateOffset { const TableNames = { clips: 'mediaRef', episodes: 'episode', - podcasts: 'podcast' + podcasts: 'podcast', + albums: 'podcast', + tracks: 'episode', + channels: 'podcast', + videos: 'episode' } enum TimeRanges { @@ -39,7 +43,7 @@ enum TimeRanges { allTime = 'pastAllTimeTotalUniquePageviews' } -export const queryUniquePageviews = async (pagePath: PagePaths, timeRange) => { +export const queryUniquePageviews = async (pagePath: string, timeRange) => { const startDateOffset = parseInt(StartDateOffset[timeRange], 10) if (!Object.keys(PagePaths).includes(pagePath)) { @@ -112,25 +116,11 @@ export const queryUniquePageviews = async (pagePath: PagePaths, timeRange) => { await savePageviewsToDatabase(pagePath, timeRange, filteredData) } -const getTableName = (pagePath: PagePaths) => { - let tableName = TableNames[pagePath] - if (pagePath === PagePaths.albums) { - tableName = TableNames['podcasts'] - } else if (pagePath === PagePaths.tracks) { - tableName = TableNames['episodes'] - } else if (pagePath === PagePaths.channels) { - tableName = TableNames['podcasts'] - } else if (pagePath === PagePaths.videos) { - tableName = TableNames['episodes'] - } - return tableName -} - -const savePageviewsToDatabase = async (pagePath: PagePaths, timeRange, data) => { +const savePageviewsToDatabase = async (pagePath: string, timeRange, data) => { await connectToDb() const matomoDataRows = data - const tableName = getTableName(pagePath) + const tableName = TableNames[pagePath] console.log('savePageviewsToDatabase') console.log('pagePath', pagePath) console.log('tableName', tableName) From f69c87e10325ea840cebdcc3ebf6a151dcc85477 Mon Sep 17 00:00:00 2001 From: Mitch Downey Date: Sun, 3 Dec 2023 15:32:26 -0600 Subject: [PATCH 2/2] Bump to version 4.15.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee9344fa..a3b9cdd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "podverse-api", - "version": "4.15.13", + "version": "4.15.14", "description": "Data API, database migration scripts, and backend services for all Podverse models.", "contributors": [ "Mitch Downey"