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 Google from '../Google'
import { StatisticType } from '../../../../../types/schemas/Statistic'

Google.prototype.getMailsStatistics = async function getMailsStatistics() {
let Nyear = 1
const mailsData = await this.getMails({
parsingOptions: {
pagination: {
offset: 0,
items: Infinity,
},
},
})

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