const mongoose = require('mongoose');

const UserBaselineSchema = new mongoose.Schema({

    userId: { type: String, required: true, unique: true },

    bloomFilter: { type: Object, required: true },

    totalEvents: { type: Number, default: 0 },

    userAgentCounts: { type: Map, of: Number, default: {} },
    countryCounts: { type: Map, of: Number, default: {} },
    timeBucketCounts: { type: Map, of: Number, default: {} },

    pendingSignatures: { type: Map, of: Number, default: {} },

    recentOpens: [{
        timestamp: Date
    }],

    averageHourlyOpens: { type: Number, default: 0 },

    lastEventAt: { type: Date }

});

module.exports = mongoose.model('UserBaseline', UserBaselineSchema);