lrf 2 gadi atpakaļ
vecāks
revīzija
ace978f7d7
1 mainītis faili ar 2 papildinājumiem un 3 dzēšanām
  1. 2 3
      app/service/statistics.js

+ 2 - 3
app/service/statistics.js

@@ -32,17 +32,16 @@ class StatisticsService extends CrudService {
     });
     query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
     const lcList = await this.lessonCoachModel.find(query).populate('lesson_id');
-    const lessonList = lcList.filter(f => f.lesson_id);
+    const lessonList = lcList.map(f => f.lesson_id);
     const arr = [];
     for (const months of monthList) {
       const s = _.head(months);
       const l = _.last(months);
       const m = moment(s).month() + 1;
       const list = lessonList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
-      console.log(list);
       const lesson_ids = list.map(i => i._id);
       const studentNumber = await this.lessonStudentModel.count({ lesson_id: lesson_ids, is_pay: '1' });
-      arr.push(studentNumber);
+      arr.push({ name: `${m}月`, value: studentNumber });
     }
     return arr;
   }