-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.js
More file actions
23 lines (21 loc) · 774 Bytes
/
stats.js
File metadata and controls
23 lines (21 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import stats from 'tweets-stats';
import maxValues from 'max-values';
import { merge } from 'ramda';
const getStatsPerAuthor = authors =>
authors
.map(author => merge(author, { followers: author.info.followers_count }))
.map((author, i, arr) => merge(author, {
gainedFollowers: arr[i + 1]
? (author.followers - arr[i + 1].followers)
: author.followers,
}))
.map(author => merge(author, stats(author.tweets)));
export default function getStats(authors) {
if (!authors || authors.length === 0) return;
return maxValues(getStatsPerAuthor(authors), [
'tweets', 'gainedFollowers',
'own.total', 'replies.total', 'retweets.total',
'favorited.total', 'favorited.average',
'retweeted.total', 'retweeted.average',
]);
}