dartmouth-cs98-23f / project-short-learning

project-short-learning created by GitHub Classroom
0 stars 0 forks source link

Simplify playlists API endpoint #105

Open jessieli24 opened 9 months ago

jessieli24 commented 9 months ago

For api/recommendations/playlists

One query item, optional topicId. Return a single playlist from the topic, or a random topic if topicId = null.

Response should include:

Something like this (but computer science-related of course)

{
  "_id": "6548124dbf672c659ae255c3",
  "title": "Fluffy Buttermilk Pancakes",
  "description": "Impossibly light, fluffy, and moist. These homemade buttermilk pancakes make an easy and satisfying breakfast for the whole family.",
  "uploadDate": "2023-11-05T22:08:13.621Z",
  "uploader": "313233343536373839313030",
  "duration": 1800,
  "thumbnailURL": "https://images.pexels.com/photos/376464/pexels-photo-376464.jpeg?cs=srgb&dl=pexels-ash-376464.jpg&fm=jpg",
  "topicId": "6548124dbf672c659ae255c3",
  "topic": "Breakfast",
  "clips": [
    {
      "_id": "6998421",
      "videoId": "6548124dbf672c659ae255c3",
      "title": "Sift dry ingredients",
      "description": "Sift flour, baking powder, sugar, and salt together in a large bowl.",
      "uploadDate": "2023-11-05T22:08:13.718Z",
      "uploader": "313233343536373839313030",
      "duration": 60,
      "thumbnailURL": "https://hlsstack-hlsbucketf901f2c8-1wlixklj3wkgx.s3.us-east-1.amazonaws.com/clip1sample.png",
      "clipURL": "https://player.vimeo.com/external/518476405.hd.mp4?s=df881ca929fbcf84aaf4040445a581a1d8e2137c&profile_id=173&oauth2_token_id=57447761",
      "views": [],
      "likes": [],
      "dislikes": [],
      "createdAt": "2023-11-05T22:08:13.721Z",
      "updatedAt": "2023-11-05T22:08:13.721Z",
      "__v": 0
    },
    {
      "_id": "6998428",
      "videoId": "6548124dbf672c659ae255c3",
      "title": "Mix until smooth",
      "description": "Combine with milk, butter, and egg. Mix until smooth.",
      "uploadDate": "2023-11-05T22:08:13.749Z",
      "uploader": "313233343536373839313030",
      "duration": 60,
      "thumbnailURL": "https://hlsstack-hlsbucketf901f2c8-1wlixklj3wkgx.s3.us-east-1.amazonaws.com/clip2sample.png",
      "clipURL": "https://player.vimeo.com/external/518111071.hd.mp4?s=39ad49273b0169602ef4b8521c98f5617229bb40&profile_id=170&oauth2_token_id=57447761",
      "views": [],
      "likes": [],
      "dislikes": [],
      "createdAt": "2023-11-05T22:08:13.750Z",
      "updatedAt": "2023-11-05T22:08:13.750Z",
      "__v": 0
    },
    {
      "_id": "7010637",
      "videoId": "6548124dbf672c659ae255c3",
      "title": "Cook pancakes on medium-high heat",
      "description": "Heat a lightly oiled griddle over medium-high heat. Pour about 1/4 cup of batter for each pancake.",
      "uploadDate": "2023-11-05T22:08:13.749Z",
      "uploader": "313233343536373839313030",
      "duration": 60,
      "thumbnailURL": "https://hlsstack-hlsbucketf901f2c8-1wlixklj3wkgx.s3.us-east-1.amazonaws.com/clip2sample.png",
      "clipURL": "https://player.vimeo.com/external/518111059.hd.mp4?s=7d71fd2315b6150c3e0f402daf2012b2fede9b8a&profile_id=174&oauth2_token_id=57447761",
      "views": [],
      "likes": [],
      "dislikes": [],
      "createdAt": "2023-11-05T22:08:13.750Z",
      "updatedAt": "2023-11-05T22:08:13.750Z",
      "__v": 0
    }
  ]
}

With this simplified endpoint, frontend can create a TaskGroup to preload a sequence by appending playlists in the order they arrive. Reduces loading time.