views.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { gql } from 'apollo-server-express'
  2. import { EntityViewsInfo } from '../../src/entities/EntityViewsInfo'
  3. export const GET_VIDEO_VIEWS = gql`
  4. query GetVideoViews($videoId: ID!) {
  5. videoViews(videoId: $videoId) {
  6. id
  7. views
  8. }
  9. }
  10. `
  11. export const GET_MOST_VIEWED_VIDEOS = gql`
  12. query GetMostViewedVideos($timePeriodDays: Int!) {
  13. mostViewedVideos(timePeriodDays: $timePeriodDays) {
  14. id
  15. views
  16. }
  17. }
  18. `
  19. export const GET_MOST_VIEWED_VIDEOS_ALL_TIME = gql`
  20. query GetMostViewedVideosAllTime($limit: Int!) {
  21. mostViewedVideosAllTime(limit: $limit) {
  22. id
  23. views
  24. }
  25. }
  26. `
  27. export type GetVideoViews = {
  28. videoViews: EntityViewsInfo | null
  29. }
  30. export type GetMostViewedVideos = {
  31. mostViewedVideos: EntityViewsInfo[]
  32. }
  33. export type GetVideoViewsArgs = {
  34. videoId: string
  35. }
  36. export type GetMostViewedVideosArgs = {
  37. timePeriodDays: number
  38. }
  39. export type GetMostViewedVideosAllTimeArgs = {
  40. limit: number
  41. }
  42. export type GetMostViewedVideosAllTime = {
  43. mostViewedVideosAllTime: EntityViewsInfo[]
  44. }
  45. export const GET_CHANNEL_VIEWS = gql`
  46. query GetChannelViews($channelId: ID!) {
  47. channelViews(channelId: $channelId) {
  48. id
  49. views
  50. }
  51. }
  52. `
  53. export const GET_MOST_VIEWED_CHANNELS = gql`
  54. query GetMostViewedChannels($timePeriodDays: Int!) {
  55. mostViewedChannels(timePeriodDays: $timePeriodDays) {
  56. id
  57. views
  58. }
  59. }
  60. `
  61. export const GET_MOST_VIEWED_CHANNELS_ALL_TIME = gql`
  62. query GetMostViewedVideosAllTime($limit: Int!) {
  63. mostViewedChannelsAllTime(limit: $limit) {
  64. id
  65. views
  66. }
  67. }
  68. `
  69. export type GetChannelViews = {
  70. channelViews: EntityViewsInfo | null
  71. }
  72. export type GetMostViewedChannels = {
  73. mostViewedChannels: EntityViewsInfo[]
  74. }
  75. export type GetChannelViewsArgs = {
  76. channelId: string
  77. }
  78. export type GetMostViewedChannelsArgs = {
  79. timePeriodDays: number
  80. }
  81. export type GetMostViewedChannelsAllTimeArgs = {
  82. limit: number
  83. }
  84. export type GetMostViewedChannelsAllTime = {
  85. mostViewedChannelsAllTime: EntityViewsInfo[]
  86. }
  87. export const GET_MOST_VIEWED_CATEGORIES = gql`
  88. query GetMostViewedCategories($timePeriodDays: Int!) {
  89. mostViewedCategories(timePeriodDays: $timePeriodDays) {
  90. id
  91. views
  92. }
  93. }
  94. `
  95. export const GET_MOST_VIEWED_CATEGORIES_ALL_TIME = gql`
  96. query GetMostViewedVideosAllTime($limit: Int!) {
  97. mostViewedCategoriesAllTime(limit: $limit) {
  98. id
  99. views
  100. }
  101. }
  102. `
  103. export type GetMostViewedCategories = {
  104. mostViewedCategories: EntityViewsInfo[]
  105. }
  106. export type GetMostViewedCategoriesArgs = {
  107. timePeriodDays: number
  108. }
  109. export type GetMostViewedCategoriesAllTimeArgs = {
  110. limit: number
  111. }
  112. export type GetMostViewedCategoriesAllTime = {
  113. mostViewedCategoriesAllTime: EntityViewsInfo[]
  114. }
  115. export const ADD_VIDEO_VIEW = gql`
  116. mutation AddVideoView($videoId: ID!, $channelId: ID!, $categoryId: ID) {
  117. addVideoView(videoId: $videoId, channelId: $channelId, categoryId: $categoryId) {
  118. id
  119. views
  120. }
  121. }
  122. `
  123. export type AddVideoView = {
  124. addVideoView: EntityViewsInfo
  125. }
  126. export type AddVideoViewArgs = {
  127. videoId: string
  128. channelId: string
  129. categoryId?: string
  130. }