Skip to content

Conversation

@gracetian6
Copy link
Contributor

@gracetian6 gracetian6 commented Jul 30, 2020

Implemented MVP backend necessary for heat map

  • ADDED likedMusicHistory array list needed for heat map
  • ex: [0, 2, 3, 4, 5, 6] means 0, 2, 3, 4, 5, 6 th latest liked videos are music
    image

@gracetian6 gracetian6 marked this pull request as ready for review July 30, 2020 16:58
@gracetian6 gracetian6 self-assigned this Jul 30, 2020
@gracetian6 gracetian6 requested review from laptou and seunomonije July 30, 2020 16:59
Base automatically changed from num-videos-backend to master July 31, 2020 00:59
@googleinterns googleinterns deleted a comment from gracetian6 Aug 3, 2020
@gracetian6 gracetian6 requested a review from seunomonije August 3, 2020 20:29
Copy link
Collaborator

@seunomonije seunomonije left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

JsonArray videos;
YoutubeGenres genreAnalysis = new YoutubeGenres();
// needed to keep track of likedMusicHistory for heat map
int videosRetrieved = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider renaming to numVideosRetrieved, videosRetrieved sounds like a list of the retrieved videos

* parses through youtube liked videos json array,
* updates hash map to contain frequency count of each music genre
* @param videos json array of youtube liked videos
* @param firstVideoCount the number of videos retrieved before this http call
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider renaming firstVideoCount to initialNumVideos. firstVideoCount sounds like it could be the index of the first video, or some count associated with the first video in the list

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Probably something like "currentVideoIndex" will be clearest


if (isMusic && totalSubgenres == 0) {
if (isMusic) {
// likedMusicHistory records video numbers that are music
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this comment, you already have a comment explaining what likedMusicHistory is when you first initialize it

JsonObject likedVideoRes;
JsonArray videos;
YoutubeGenres genreAnalysis = new YoutubeGenres();
// needed to keep track of likedMusicHistory for heat map
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment doesn't really make sense to me, since it's not "keeping track" of likedMusicHistory but being used by it. likedMusicHistory also isn't part of this file, so that could come of as confusing to someone only looking at this file. consider rephrasing to something like "used to determine the position of a newly retrieved video in comparison to already retrieved videos while obtaining more videos in segments"


videos = likedVideoRes.getAsJsonArray("items");
genreAnalysis.calculateMusicCount(videos);
// videosRetrieved keeps track of music video order in genreAnalysis
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this comment since you already have a comment defining what this variable is when you initiated it

* parses through youtube liked videos json array,
* updates hash map to contain frequency count of each music genre
* @param videos json array of youtube liked videos
* @param firstVideoCount the number of videos retrieved before this http call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Probably something like "currentVideoIndex" will be clearest

}
}
return;
return videosSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get this info from the parent function. No need to return it here, and that in fact obscures what this function is doing, since it analyzes the videos but also returns the total number. Someone interacting with this function will likely write:

totalVideos += calculateMusicVideos(videos, totalVideos);

This means 2 independent things are happening on one line that aren't strictly tied together. More clear is:

calculateMusicVideos(videos, totalVideos);
totalVideos += videos.size();

Comment on lines +119 to +120
videosRetrieved += genreAnalysis
.calculateMusicCount(videos, videosRetrieved);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. This should be split into 2 separate lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants