mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 20:11:32 +02:00
[misc] add scripts for rotating all the encrypted access-tokens GitOrigin-RevId: ce3374bb5d318a7f16a416ac1719a819c1160fb4
21 lines
631 B
JavaScript
21 lines
631 B
JavaScript
function formatTokenUsageStats(STATS) {
|
|
const prettyStats = []
|
|
const sortedStats = Object.entries(STATS).sort((a, b) =>
|
|
a[0] > b[0] ? 1 : -1
|
|
)
|
|
const totalByName = {}
|
|
for (const [key, n] of sortedStats) {
|
|
const [name, version, collectionName, path, label] = key.split(':')
|
|
totalByName[name] = (totalByName[name] || 0) + n
|
|
prettyStats.push({ name, version, collectionName, path, label, n })
|
|
}
|
|
for (const row of prettyStats) {
|
|
row.percentage = ((100 * row.n) / totalByName[row.name])
|
|
.toFixed(2)
|
|
.padStart(6)
|
|
}
|
|
console.table(prettyStats)
|
|
}
|
|
|
|
module.exports = { formatTokenUsageStats }
|