internal static IQueryOver <ExerciseProfileData, ExerciseProfileData> PublicRecordsQueryCriteria(IQueryOver <ExerciseProfileData, ExerciseProfileData> query, Profile profile) { ProfileStatistics stat = null; query = query.JoinAlias(x => profile.Statistics, () => stat); query = query.Where(x => (stat.StrengthTrainingEntriesCount >= Portable.Constants.StrengthTrainingEntriesCount || stat.TrainingDaysCount >= Portable.Constants.PublicTrainingDaysCount) && x.Customer == null); return(query); }
public PlayerData(ProfileStatistics profileStatistics) { pvp_wins = profileStatistics.pvp_wins; pvp_losses = profileStatistics.pvp_losses; ai_wins = profileStatistics.ai_wins; ai_losses = profileStatistics.ai_losses; friend_wins = profileStatistics.friend_wins; friend_losses = profileStatistics.friend_losses; }
public async Task <ProfileStatistics> GetProfileStatistics(string userName) { var cacheKey = userName; _cache.TryGetValue(cacheKey, out ProfileStatistics existing); if (existing != null) { return(existing); } var entities = await _twitterAdapter.GetAllTweets(userName); var tweets = entities.Select(x => x.Text).ToList(); var topWordsTask = GetTopWords(tweets); var unifiedEntities = await _generalizationService.UnifyContent(tweets); var textEntries = unifiedEntities.Select(x => new TextEntry { OriginId = x.OriginId, Text = x.Unified }).ToList(); var positiveSentimentTask = _sentimentService.DetectPositiveSentiments(textEntries); var toxicSentimentTask = _sentimentService.DetectToxicSentiments(textEntries); await Task.WhenAll(positiveSentimentTask, toxicSentimentTask, topWordsTask); await Task.WhenAll(topWordsTask); var positiveSentiment = positiveSentimentTask.Result.ToDictionary(x => x.OriginId); var toxicSentiment = toxicSentimentTask.Result.ToDictionary(x => x.OriginId); var topWords = topWordsTask.Result; var responseRecords = unifiedEntities.Select(x => new Statistics { Text = x.Origin, SentimentScore = new SentimentScore { Score = positiveSentiment[x.OriginId].SentimentScore.ToDictionary(t => t.Key, t => t.Value), Label = positiveSentiment[x.OriginId].SentimentType }, ToxicityScore = new ToxicityScore { Value = toxicSentiment[x.OriginId].Score, Label = toxicSentiment[x.OriginId].Score >= 0.5 ? "Toxic" : "Non-toxic" } }).ToList(); var profileSentiment = GetProfileLabel(responseRecords.Select(x => x.SentimentScore)); var profileToxicity = GetProfileLabel(responseRecords.Select(x => x.ToxicityScore)); var response = new ProfileStatistics { ProfileSentimentLabel = profileSentiment, ProfileToxicityLabel = profileToxicity, Records = responseRecords, TopWords = topWords }; _cache.Set(cacheKey, response); return(response); }