views.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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($period: Int!) {
  13. mostViewedVideos(period: $period) {
  14. id
  15. views
  16. }
  17. }
  18. `
  19. export type GetVideoViews = {
  20. videoViews: EntityViewsInfo | null
  21. }
  22. export type GetMostViewedVideos = {
  23. mostViewedVideos: EntityViewsInfo[]
  24. }
  25. export type GetVideoViewsArgs = {
  26. videoId: string
  27. }
  28. export type GetMostViewedVideosArgs = {
  29. period: number
  30. }
  31. export const GET_CHANNEL_VIEWS = gql`
  32. query GetChannelViews($channelId: ID!) {
  33. channelViews(channelId: $channelId) {
  34. id
  35. views
  36. }
  37. }
  38. `
  39. export const GET_MOST_VIEWED_CHANNELS = gql`
  40. query GetMostViewedChannels($period: Int!) {
  41. mostViewedChannels(period: $period) {
  42. id
  43. views
  44. }
  45. }
  46. `
  47. export type GetChannelViews = {
  48. channelViews: EntityViewsInfo | null
  49. }
  50. export type GetMostViewedChannels = {
  51. mostViewedChannels: EntityViewsInfo[]
  52. }
  53. export type GetChannelViewsArgs = {
  54. channelId: string
  55. }
  56. export type GetMostViewedChannelsArgs = {
  57. period: number
  58. }
  59. export const GET_MOST_VIEWED_CATEGORIES = gql`
  60. query GetMostViewedCategories($period: Int!) {
  61. mostViewedCategories(period: $period) {
  62. id
  63. views
  64. }
  65. }
  66. `
  67. export type GetMostViewedCategories = {
  68. mostViewedCategories: EntityViewsInfo[]
  69. }
  70. export type GetMostViewedCategoriessArgs = {
  71. period: number
  72. }
  73. export const ADD_VIDEO_VIEW = gql`
  74. mutation AddVideoView($videoId: ID!, $channelId: ID!, $categoryId: ID) {
  75. addVideoView(videoId: $videoId, channelId: $channelId, categoryId: $categoryId) {
  76. id
  77. views
  78. }
  79. }
  80. `
  81. export type AddVideoView = {
  82. addVideoView: EntityViewsInfo
  83. }
  84. export type AddVideoViewArgs = {
  85. videoId: string
  86. channelId: string
  87. categoryId?: string
  88. }