const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const admin_metrics_snapshots = sequelize.define(
    'admin_metrics_snapshots',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

snapshot_at: {
        type: DataTypes.DATE,
      
      

      },

total_accounts: {
        type: DataTypes.INTEGER,
      
      

      },

total_users: {
        type: DataTypes.INTEGER,
      
      

      },

total_patients: {
        type: DataTypes.INTEGER,
      
      

      },

active_devices: {
        type: DataTypes.INTEGER,
      
      

      },

alerts_last_24h: {
        type: DataTypes.INTEGER,
      
      

      },

cognitive_sessions_last_7d: {
        type: DataTypes.INTEGER,
      
      

      },

reminders_sent_last_24h: {
        type: DataTypes.INTEGER,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  admin_metrics_snapshots.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity





























//end loop



    db.admin_metrics_snapshots.belongsTo(db.accounts, {
      as: 'accounts',
      foreignKey: {
        name: 'accountsId',
      },
      constraints: false,
    });




    db.admin_metrics_snapshots.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.admin_metrics_snapshots.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return admin_metrics_snapshots;
};


