/// <summary> /// Gets the personalized video suggestions for a specific user. /// </summary> public async Task <Dtos.SuggestedVideos> GetSuggestions(SuggestedVideosQuery query) { // Return the output of a Spark job that runs periodically in the background to populate the video_recommendations table // (see the /data/spark folder in the repo for more information) PreparedStatement prepared = await _statementCache.NoContext.GetOrAddAsync( "SELECT videoid, authorid, name, added_date, preview_image_location FROM video_recommendations WHERE userid=?"); IStatement bound = prepared.Bind(query.UserId) .SetAutoPage(false) .SetPageSize(query.PageSize); // The initial query won't have a paging state, but subsequent calls should if there are more pages if (string.IsNullOrEmpty(query.PagingState) == false) { bound.SetPagingState(Convert.FromBase64String(query.PagingState)); } RowSet rows = await _session.ExecuteAsync(bound).ConfigureAwait(false); return(new Dtos.SuggestedVideos() { UserId = query.UserId, Videos = rows.Select(MapRowToVideoPreview).ToList(), PagingState = rows.PagingState != null && rows.PagingState.Length > 0 ? Convert.ToBase64String(rows.PagingState) : null }); }
/// <summary> /// Gets the personalized video suggestions for a specific user. /// </summary> public Task <Dtos.SuggestedVideos> GetSuggestions(SuggestedVideosQuery query) { // TODO: Can we implement suggestions without DSE and Spark? var result = new Dtos.SuggestedVideos() { UserId = query.UserId, Videos = Enumerable.Empty <VideoPreview>(), PagingState = null }; return(Task.FromResult(result)); }