// venue-channel.js
// Copyright (C) 2022 DTP Technologies, LLC
// License: Apache-2.0

'use strict';

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const LiveEpisodeSchema = new Schema({
  created: { type: Date },
  updated: { type: Date },
  title: { type: String },
  description: { type: String },
  status: { type: String },
  stats: {
    totalViewCount: { type: Number },
    peakViewerCount: { type: Number },
    currentViewerCount: { type: Number },
    dvrViewCount: { type: Number },
    chatMessageCount: { type: Number },
    minutesViewed: { type: Number },
    megabitsSent: { type: Number },
    megabitsRecv: { type: Number },
    subscriberCount: { type: Number },
    reactionCount: { type: Number },
  },
});

const VenueChannelStatusSchema = new Schema({
  created: { type: Date, default: Date.now, required: true, index: -1 },
  channel: { type: Schema.ObjectId, required: true, index: 1, ref: 'VenueChannel' },
  isLive: { type: Boolean },
  status: { type: String },
  lastLive: { type: Date },
  name: { type: String },
  description: { type: String },
  thumbnailUrl: { type: String },
  liveEpisode: { type: LiveEpisodeSchema },
  liveThumbnail: {
    url: { type: String },
  },
});

module.exports = mongoose.model('VenueChannelStatus', VenueChannelStatusSchema);