Skip to content
Snippets Groups Projects
Commit 4f2f43f8 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

change services file extension from js to ts

parent 220b5b64
No related branches found
No related tags found
3 merge requests!103Support,!102Dev,!83Features/113 bilan mensuel
......@@ -24,7 +24,7 @@
"services": {
"monthlyReport": {
"type": "node",
"file": "monthlyReport.js",
"file": "monthlyReport.ts",
"trigger": "@cron 0 0 * * * *"
}
},
......
import moment from 'moment-timezone'
// import { ENEDIS_DAY_DOCTYPE, GRDF_DAY_DOCTYPE, EGL_DAY_DOCTYPE } from 'doctypes'
import logger from 'cozy-logger'
// import { sumBy } from 'lodash'
import { runService } from './service'
moment.tz.setDefault('Europe/Paris')
const log = logger.namespace('monthly_summary')
// Get last month limits
// const getPeriod = () => {
// const end = moment().startOf('month')
// const start = end
// .clone()
// .subtract(1, 'month')
// .startOf('month')
// end = start.clone().endOf('month')
// return { start, end }
// }
// const fetchConsumptionsForPeriod = period => {
// return ENEDIS_DAY_DOCTYPE.queryAll({
// date: {
// $gte: period.start,
// $lt: period.end,
// },
// })
// }
// const getMeanOnPeriod = (consumptions, period) => {
// const end = moment(period.end)
// const start = moment(period.start)
// const nbdays = end.diff(start, 'days')
// const total = Math.abs(
// sumBy(consumptions, consumptions => consumptions.value)
// )
// const mean = total / nbdays
// return mean
// }
const monthlySummaryStats = async () => {
log('info', 'Fetching datas...')
// const period = getPeriod()
// const consumptions = await fetchConsumptionsForPeriod(period)
// const meanConsumptions = getMeanOnPeriod(consumptions, period)
// const FEEDBACK_EMAIL = 'ecolyo@grandlyon.com'
// const mailContent = 'TEST'
// const mailData = {
// mode: 'from',
// to: [{ name: 'Support', email: FEEDBACK_EMAIL }],
// subject: '[Ecolyo] - Votre bilan mensuel',
// parts: [{ type: 'text/plain', body: mailContent }],
// }
// try {
// const jobCollection = client.collection('io.cozy.jobs')
// await jobCollection.create('sendmail', mailData)
// } catch (e) {
// // eslint-disable-next-line no-console
// console.error(e)
// setError(t('feedback.error_sending'))
// }
// log(
// 'info',
// `${consumptions.length} consumptions between ${period.start} and ${period.end}`
// )
//create doctype ecran stats
}
runService(monthlySummaryStats)
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment