Added !list command
This commit is contained in:
parent
ef694b116f
commit
5a15cdf7b4
8 changed files with 211 additions and 77 deletions
|
@ -1,56 +0,0 @@
|
|||
const moment = require('moment')
|
||||
|
||||
/**
|
||||
* Fonction permettant de générer le filtre de date sur les commandes !stats et !when
|
||||
* @param {String} period
|
||||
*/
|
||||
function setPeriod (period) {
|
||||
switch (period) {
|
||||
case 'day':
|
||||
return {
|
||||
$gte: moment().startOf('day'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'week':
|
||||
return {
|
||||
$gte: moment().startOf('week'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'month':
|
||||
return {
|
||||
$gte: moment().startOf('month'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'year':
|
||||
return {
|
||||
$gte: moment().startOf('year'),
|
||||
$lte: moment().endOf('day')
|
||||
}
|
||||
case 'lastday':
|
||||
return {
|
||||
$gte: moment().subtract('day').startOf('day'),
|
||||
$lte: moment().subtract('day').endOf('day')
|
||||
}
|
||||
case 'lastweek':
|
||||
return {
|
||||
$gte: moment().subtract(1, 'week').startOf('week'),
|
||||
$lte: moment().subtract(1, 'week').endOf('week')
|
||||
}
|
||||
case 'lastmonth':
|
||||
return {
|
||||
$gte: moment().subtract(1, 'month').startOf('month'),
|
||||
$lte: moment().subtract(1, 'month').endOf('month')
|
||||
}
|
||||
case 'lastyear':
|
||||
return {
|
||||
$gte: moment().subtract(1, 'year').startOf('year'),
|
||||
$lte: moment().subtract(1, 'year').endOf('year')
|
||||
}
|
||||
default:
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setPeriod: setPeriod
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue