Skip to content

Commit

Permalink
Merge pull request #709 from podverse/develop
Browse files Browse the repository at this point in the history
Release v4.15.14
  • Loading branch information
mitchdowney authored Dec 3, 2023
2 parents dfce5e6 + f69c87e commit 1529707
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
34 changes: 12 additions & 22 deletions src/services/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1529707

Please sign in to comment.