/
oinktech
/
readmef
Обзор
Документация
Войти
/
oinktech
/
readmef
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
master
server/lib/aggregate.js
30 строк
963 B
TwixoffStudio
Create: package-lock.json, README.md, app.js, index.html, styles.css, index.js, aggregate.js, cache.js, readmeBuilder.js, svg.js, theme.js, base.js, github.js, gitverse.js, index.js, routes.js, .env.example, LICENSE, package.json
05 июл 2026, 13:09
Верифицирован
05 июл 2026, 13:09
dc3c4b9
Код
Авторство
О чём код?
'use strict'; // Никакого ИИ — просто арифметика по данным, которые уже вернул провайдер. function aggregateStats(viewer, repos) { const owned = repos.filter((r) => !r.fork); const totalStars = owned.reduce((s, r) => s + (r.stars || 0), 0); const totalForks = owned.reduce((s, r) => s + (r.forks || 0), 0); const langCount = new Map(); for (const r of owned) { if (!r.language) continue; langCount.set(r.language, (langCount.get(r.language) || 0) + 1); } const langs = [...langCount.entries()] .map(([name, count]) => ({ name, count })) .sort((a, b) => b.count - a.count); const topRepos = [...owned].sort((a, b) => (b.stars || 0) - (a.stars || 0)).slice(0, 6); return { publicRepos: viewer.publicRepos ?? owned.length, followers: viewer.followers ?? 0, totalStars, totalForks, langs, topRepos, }; } module.exports = { aggregateStats };