async function getAmountsPerPeriods(Model, objectName){

  const totalDocumentAmount = await Model.estimatedDocumentCount({});

  if(logCaching == 'true'){
    console.log(`Got total ${objectName} counted`);
  }

  // build dates
  var monthAgo =  moment().subtract(30, 'days').toDate();
  var weekAgo =  moment().subtract(7, 'days').toDate();
  var dayAgo = moment().subtract(24, 'hours').toDate();
  var hourAgo = moment().subtract(1, 'hours').toDate();
  var minuteAgo = moment().subtract(1, 'minutes').toDate();

  // find the views
  const lastMonthAmount= await Model.countDocuments({ createdAt: { $gte: monthAgo } });
  const lastWeekAmount = await Model.countDocuments({ createdAt: { $gte: weekAgo } });
  const lastDayAmount = await Model.countDocuments({ createdAt: { $gte: dayAgo } });
  const lastHourAmount = await Model.countDocuments({ createdAt: { $gte: hourAgo } });
  const lastMinuteAmount = await Model.countDocuments({ createdAt: { $gte: minuteAgo } });

  return{
    name: objectName,
    alltime: totalDocumentAmount,
    month: lastMonthAmount,
    week: lastWeekAmount,
    day: lastDayAmount,
    hour: lastHourAmount,
    minute: lastMinuteAmount
  };
}
THIS IS FOR DAILY STATS, VIEWS ALSO USED IN POPULAR *