Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Facebook from '../Facebook'
import { StatisticType } from '../../../../../types/schemas/Statistic'

Facebook.prototype.getFollowingsStatistics = async function getFollowingsStatistics() {
let Nyear = 1
const followingData = await this.getFollowings({
parsingOptions: {
pagination: {
offset: 0,
items: Infinity,
},
},
})

if (!followingData) {
return null
}
followingData.data.forEach((entry) => {
const end = new Date(new Date().setFullYear(new Date().getFullYear() - Nyear))
for (Nyear; entry.followedSince! < end; Nyear += 1) {
Nyear += 1
break
}
})
return {
statistics: [
{
type: StatisticType.NUMBER,
value: (followingData.data.length / Nyear).toFixed(2),
name: 'Following over Time',
},
],
parsedFiles: followingData?.parsedFiles ?? [],
}
}