type Channel @key(fields: "channelId") {
    channelId: String!
    analytics: ChannelAnalytics!
    following: Boolean!
    dateFollowed: Date
}

type ChannelResults {
    channels: [Channel!]!
    totalCount: Int!
}

type ChannelAnalytics {
    daily(storeIds: [Int!], countries: [String!], distributors: [Distributor!], startDate: String!, days: Int!): DailyChannelAnalytics!
    allTime(storeIds: [Int!], countries: [String!], distributors: [Distributor!]): AllTimeChannelAnalytics!
    topTrafficSources(storeIds: [Int!], countries: [String!], startDate: String, distributors: [Distributor!], days: Int, limit: Int): TopChannelTrafficSources!
    topVideos(storeIds: [Int!], countries: [String!], startDate: String, days: Int, limit: Int, distributors: [Distributor!]): TopChannelVideos!
    topCountries(storeIds: [Int!], startDate: String!, distributors: [Distributor!], days: Int!): TopCountriesByChannels!
    "This field is only populated by the topChannels query"
    metrics: ChannelCatalogMetrics
}

type DailyChannelAnalytics {
    data: [ChannelAnalyticsData]!
    aggregate: ChannelAnalyticsData!
    sources: [Store]!
}

type AllTimeChannelAnalytics {
    data: ChannelAnalyticsData!
    sources: [Store]!
}

type ChannelCatalogMetrics {
  subscribers: Long!
  views: Long!
  estimatedGrossRevenue: Float!
  averageViewDurationSeconds: Float!
  growthPeriods: [DeltaGrowth!]!
  lastAvailableDate: Date!
}

type ChannelAnalyticsData {
    channelId: String!
    downloadActivityDate: Date
    views: Long
    premiumViews: Long
    averageViewDurationSeconds: Float
    averageViewDurationPercentage: Float
    watchTimeMinutes: Float
    premiumWatchTimeMinutes: Float
    impressionsCtr: Float
    estimatedPartnerAdRevenue: Float
    estimatedPartnerPremiumRevenue: Float
    estimatedMonetizedPlaybacks: Long
    cpm: Float
    rpm: Float
    adFillRate: Float
    comments: Long
}

# @deprecated Please use fields on ChannelAnalyticsData
type ChannelMetricData {
    channelId: String
    downloadActivityDate: Date
    views: Long
    premiumViews: Long
    averageViewDurationSeconds: Float
    averageViewDurationPercentage: Float
    watchTimeMinutes: Float
    premiumWatchTimeMinutes: Float
    impressionsCtr: Float
    estimatedPartnerAdRevenue: Float
    estimatedPartnerPremiumRevenue: Float
    estimatedMonetizedPlaybacks: Long
    cpm: Float
    rpm: Float
    adFillRate: Float
    comments: Long
}

# @deprecated Please use fields on ChannelAnalyticsData
type ChannelMetricAggregateData {
    channelId: String
    views: Long
    premiumViews: Long
    averageViewDurationSeconds: Float
    averageViewDurationPercentage: Float
    watchTimeMinutes: Float
    premiumWatchTimeMinutes: Float
    impressionsCtr: Float
    estimatedPartnerAdRevenue: Float
    estimatedPartnerPremiumRevenue: Float
    estimatedMonetizedPlaybacks: Long
    cpm: Float
    rpm: Float
    adFillRate: Float
    comments: Long
}

type ChannelTrafficSources {
    source: String!
    views: Long!
    premiumViews: Long!
    averageViewDurationSeconds: Float!
    averageViewDurationPercentage: Float!
    watchTimeMinutes: Float!
    premiumWatchTimeMinutes: Float!
}

type TopChannelTrafficSources {
    channelTrafficSources: [ChannelTrafficSources!]!
    sources: [Store!]!
}

type TopChannelVideos {
    channelVideos: [ChannelVideo!]!
    sources: [Store!]!
}

type ChannelVideo {
    videoId: String! @deprecated(reason: "Use `video.videoId`")
    video: Video!
    views: Long!
    premiumViews: Long!
    averageViewDurationSeconds: Float!
    averageViewDurationPercentage: Float!
    watchTimeMinutes: Float!
    premiumWatchTimeMinutes: Float!
}
