public override async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue, BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults) { while (await entitiesInfoQueue.OutputAvailableAsync()) { BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync(); var movieTmdbInfo = (TmdbMovieInfo)entityInfo; double rating = _fuzzyController.CalculateRating( movieTmdbInfo.VoteCount, movieTmdbInfo.VoteAverage, movieTmdbInfo.ReleaseDate.Year, movieTmdbInfo.Popularity, movieTmdbInfo.Adult ? 1 : 0 ); var resultInfo = new RatingDataContainer(entityInfo, rating); await entitiesRatingQueue.SendAsync(resultInfo); if (outputResults) { GlobalMessageHandler.OutputMessage($"Appraised {resultInfo} by {Tag}"); } } return(true); }
public virtual async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue, BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults) { while (await entitiesInfoQueue.OutputAvailableAsync()) { BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync(); var resultInfo = new RatingDataContainer(entityInfo, entityInfo.VoteAverage); await entitiesRatingQueue.SendAsync(resultInfo); if (outputResults) { GlobalMessageHandler.OutputMessage(resultInfo.ToString()); } } return(true); }
public override async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue, BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults) { while (await entitiesInfoQueue.OutputAvailableAsync()) { BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync(); var gameInfo = (OmdbMovieInfo)entityInfo; var resultInfo = new RatingDataContainer(entityInfo, gameInfo.VoteAverage); await entitiesRatingQueue.SendAsync(resultInfo); if (outputResults) { GlobalMessageHandler.OutputMessage($"Appraised {resultInfo} by {Tag}"); } } return(true); }
public RatingDataContainer GetRatings(BasicInfo entityInfo, bool outputResults) { if (!(entityInfo is T convertedInfo)) { throw new ArgumentException( $"Element \"{entityInfo.Title}\" (ID = {entityInfo.ThingId.ToString()}) " + $"type \"{entityInfo.GetType().FullName}\" is invalid for appraiser with " + $"type \"{TypeId.FullName}\"." ); } double ratingValue = _appraisal.CalculateRating(convertedInfo); var resultInfo = new RatingDataContainer(entityInfo, ratingValue, RatingId); if (outputResults) { GlobalMessageHandler.OutputMessage(resultInfo.ToString()); } return(resultInfo); }