/***
 *
 * @description This model represent the statistics collection schema in mongodb
 * * source : https://mongoosejs.com/docs/guide.html
 */

import mongoose, { Model } from 'mongoose';
import { IStatisticsSchema } from '@/types/IDB';

const statisticsSchema = new mongoose.Schema<IStatisticsSchema>({
  listsTracking : {
      thisWeek : {
        'year': Number,
        'month': Number,
        'week': Number,
        'days': {
          'sat': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          },
          'sun': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          },
          'mon': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          },
          'tue': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          },
          'wed': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          },
          'thu': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          },
          'fri': {
            'totalMembers': {
              type: Number,
              default: 0,
            },
            'totalActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalUnActiveSubs': {
              type: Number,
              default: 0,
            },
            'totalMansMembers': {
              type: Number,
              default: 0,
            },
            'totalGirlsMembers': {
              type: Number,
              default: 0,
            },
          }
        }
      },
      months : [{
          'year': Number,
          'month': Number,
          'weeks': [{
            'week': Number,
            'days': [{
              'sat': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              },
              'sun': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              },
              'mon': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              },
              'tue': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              },
              'wed': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              },
              'thu': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              },
              'fri': {
                'totalMembers': Number,
                'totalActiveSubs': Number,
                'totalUnActiveSubs': Number,
                'totalMansMembers': Number,
                'totalGirlsMembers': Number,
              }
            }]
          }]
      }],
      years : [{
          'year': Number,
          'months': [{
              'month': Number,
              'weeks': [{
                  'week': Number,
                  'days': [{
                    'sat': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    },
                    'sun': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    },
                    'mon': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    },
                    'tue': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    },
                    'wed': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    },
                    'thu': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    },
                    'fri': {
                        'totalMembers': Number,
                        'totalActiveSubs': Number,
                        'totalUnActiveSubs': Number,
                        'totalMansMembers': Number,
                        'totalGirlsMembers': Number,
                    }
                  }]
              }]
          }]
      }]
  },
  totalIncome: Number,
  totalOutcome: Number,
}, { timestamps: true });

const statisticsModel: Model<IStatisticsSchema> = mongoose.models.statistics || mongoose.model<IStatisticsSchema>('statistics', statisticsSchema);
export default statisticsModel