Skip to content

Commit

Permalink
chore: release 4.4.1 (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaunoT authored Oct 14, 2024
2 parents 2668327 + 5b8a4ae commit 22bba8d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"stylelint.vscode-stylelint",
"csstools.postcss"
"stylelint.vscode-stylelint"
]
}
11 changes: 4 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"typescript",
"typescriptreact"
],
"css.validate": false,
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand All @@ -20,15 +19,13 @@
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.documentSelectors": ["**/*.svg"],
"css.validate": false,
"stylelint.packageManager": "pnpm",
"stylelint.snippet": ["css", "postcss"],
"stylelint.validate": ["css", "postcss"],
"typescript.tsdk": "node_modules/typescript/lib",
"prettier.documentSelectors": ["**/*.svg"],
"files.associations": {
"*.css": "postcss"
"*.css": "tailwindcss"
},
"tailwindCSS.experimental.classRegex": [
["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
]
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ _Please note that supporting does not guarantee any support or future developmen

To learn more about some of the tools used in this project, take a look at the following resources:

- [Tautulli API reference](https://github.com/Tautulli/Tautulli/wiki/Tautulli-API-Reference)
- [Tautulli API reference](https://docs.tautulli.com/extending-tautulli/api-reference)
- [Overseerr API reference](https://api-docs.overseerr.dev)
- [Next.js docs](https://nextjs.org/docs)
- [NextAuth.js docs](https://next-auth.js.org/getting-started/introduction)
42 changes: 32 additions & 10 deletions src/utils/getUsersTop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TautulliItem, TautulliItemRow } from '@/types/tautulli'
import { fetchOverseerrStats, fetchOverseerrUserId } from './fetchOverseerr'
import fetchTautulli, {
getLibraries,
getLibrariesByType,
getUsersCount,
} from './fetchTautulli'
Expand Down Expand Up @@ -29,18 +30,39 @@ export default async function getUsersTop(
return null
}

const usersRes = await fetchTautulli<TautulliItem>('get_home_stats', {
stat_id: 'top_users',
stats_count: allUsersCount,
stats_type: 'duration',
...(after && before ? { after, before } : { time_range: period || '30' }),
})
const users = usersRes?.response?.data?.rows
const activeLibraries = await getLibraries()
const userStats = await Promise.all(
activeLibraries.map((library) =>
fetchTautulli<TautulliItem>('get_home_stats', {
stat_id: 'top_users',
stats_count: allUsersCount,
stats_type: 'duration',
section_id: library.section_id,
...(after && before
? { after, before }
: { time_range: period || '30' }),
}),
),
)
const combinedUserStats: { [userId: string]: TautulliItemRow } = {}

if (!users) {
return null
}
userStats.forEach((stat) => {
const users = stat?.response?.data?.rows

if (users) {
users.forEach((user) => {
if (combinedUserStats[user.user_id]) {
combinedUserStats[user.user_id].total_duration += user.total_duration
} else {
combinedUserStats[user.user_id] = { ...user }
}
})
}
})

const users = Object.values(combinedUserStats).sort(
(a, b) => b.total_duration - a.total_duration,
)
const isAnonymousAccess = settings.general.isOutsideAccess && !loggedInUserId
const listedUsers = isAnonymousAccess
? users.slice(0, numberOfUsers)
Expand Down

0 comments on commit 22bba8d

Please sign in to comment.