Skip to content

Commit

Permalink
Merge pull request #751 from podverse/develop
Browse files Browse the repository at this point in the history
Release v4.16.17
  • Loading branch information
mitchdowney authored Apr 27, 2024
2 parents bee5df8 + bd986c7 commit 9456938
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 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.16.16",
"version": "4.16.17",
"description": "Data API, database migration scripts, and backend services for all Podverse models.",
"contributors": [
"Mitch Downey"
Expand Down
12 changes: 6 additions & 6 deletions src/lib/utility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const addOrderByToQuery = (qb, type, sort, sortDateKey, allowRandom, isFr
`${type}.id = stats_${type}.${statsParentId}_id AND stats_${type}.timeframe = :timeframe`,
{ timeframe: 'daily' }
)
qb.addOrderBy(`CASE WHEN stats_${type}.play_count IS NULL THEN 1 ELSE 0 END`, 'ASC')

qb.addOrderBy(`stats_${type}.play_count`, descKey)
} else if (sort === 'top-past-week') {
qb.leftJoin(
Expand All @@ -166,7 +166,7 @@ export const addOrderByToQuery = (qb, type, sort, sortDateKey, allowRandom, isFr
`${type}.id = stats_${type}.${statsParentId}_id AND stats_${type}.timeframe = :timeframe`,
{ timeframe: 'weekly' }
)
qb.addOrderBy(`CASE WHEN stats_${type}.play_count IS NULL THEN 1 ELSE 0 END`, 'ASC')

qb.addOrderBy(`stats_${type}.play_count`, descKey)
} else if (sort === 'top-past-month') {
qb.leftJoin(
Expand All @@ -175,7 +175,7 @@ export const addOrderByToQuery = (qb, type, sort, sortDateKey, allowRandom, isFr
`${type}.id = stats_${type}.${statsParentId}_id AND stats_${type}.timeframe = :timeframe`,
{ timeframe: 'monthly' }
)
qb.addOrderBy(`CASE WHEN stats_${type}.play_count IS NULL THEN 1 ELSE 0 END`, 'ASC')

qb.addOrderBy(`stats_${type}.play_count`, descKey)
} else if (sort === 'top-past-year') {
qb.leftJoin(
Expand All @@ -184,7 +184,7 @@ export const addOrderByToQuery = (qb, type, sort, sortDateKey, allowRandom, isFr
`${type}.id = stats_${type}.${statsParentId}_id AND stats_${type}.timeframe = :timeframe`,
{ timeframe: 'yearly' }
)
qb.addOrderBy(`CASE WHEN stats_${type}.play_count IS NULL THEN 1 ELSE 0 END`, 'ASC')

qb.addOrderBy(`stats_${type}.play_count`, descKey)
} else if (sort === 'top-all-time') {
qb.leftJoin(
Expand All @@ -193,7 +193,7 @@ export const addOrderByToQuery = (qb, type, sort, sortDateKey, allowRandom, isFr
`${type}.id = stats_${type}.${statsParentId}_id AND stats_${type}.timeframe = :timeframe`,
{ timeframe: 'all_time' }
)
qb.addOrderBy(`CASE WHEN stats_${type}.play_count IS NULL THEN 1 ELSE 0 END`, 'ASC')

qb.addOrderBy(`stats_${type}.play_count`, descKey)
} else if (sort === 'most-recent') {
qb.orderBy(`${type}.${sortDateKey}`, descKey)
Expand All @@ -216,7 +216,7 @@ export const addOrderByToQuery = (qb, type, sort, sortDateKey, allowRandom, isFr
`${type}.id = stats_${type}.${type}_id AND stats_${type}.timeframe = :timeframe`,
{ timeframe: 'weekly' }
)
qb.addOrderBy(`CASE WHEN stats_${type}.play_count IS NULL THEN 1 ELSE 0 END`, 'ASC')

qb.addOrderBy(`stats_${type}.play_count`, descKey)
}

Expand Down

0 comments on commit 9456938

Please sign in to comment.