Exemple #1
0
        private float qualityInfluencePreservationFactor(PostAdapter i_Post)
        {
            float postInfluencePreservation = 0;

            foreach (KeyValuePair <UserAdapter, int> userLikesPair in m_UsersSortedByLikes)
            {
                if (i_Post.LikedBy.Contains(userLikesPair.Key))
                {
                    postInfluencePreservation += userLikesPair.Value / this.m_PostsDataAggregator.TotalNumberOfLikesRecievedInAllPosts;
                }
            }

            return(postInfluencePreservation);
        }
 public void displayPostToPreview(PostAdapter i_Post)
 {
     try
     {
         r_FormToPopulate.TextBoxPostAnalyzerPreview.Text = string.Format(
             @"POSTED AT:{0}{1}CONTENT:{2}",
             i_Post?.CreatedTime?.ToString(),
             System.Environment.NewLine,
             i_Post?.Message);
     }
     catch (Exception e)
     {
         r_FormToPopulate.DisplayErrorDialog(string.Format("Something went wrong in displaying the preview for the selected post.{1}Advanced:{0}", e.Message, Environment.NewLine));
     }
 }
Exemple #3
0
        private float quantitiveInfluencePreservationFactor(PostAdapter i_Post)
        {
            float m_quantitiveInfluencePreservationFactor = 0f;

            if (m_PostsDataAggregator.AvarageCountOfLikesPerPost != 0)
            {
                m_quantitiveInfluencePreservationFactor = i_Post.LikedBy.Count / m_PostsDataAggregator.AvarageCountOfLikesPerPost;
                if (m_quantitiveInfluencePreservationFactor > 1)
                {
                    m_quantitiveInfluencePreservationFactor = 1f;
                }
            }

            return(m_quantitiveInfluencePreservationFactor);
        }
Exemple #4
0
        internal int GetPostInfluenceLevel(PostAdapter i_Post)
        {
            int postInfluenceLevel = 0;

            if (this.m_User.Posts.Contains(i_Post))
            {
                postInfluenceLevel = AnalysePostInfluenceLevel(i_Post);
            }
            else
            {
                throw new Exception("The post you requested was not found!");
            }

            return(postInfluenceLevel);
        }
Exemple #5
0
        private int AnalysePostInfluenceLevel(PostAdapter i_Post)
        {
            int postInfluenceLevel = 0;

            // If the post got more likes than average, it gets 30% of the grade
            if (i_Post.LikedBy.Count > this.m_PostsDataAggregator.AvarageCountOfLikesPerPost)
            {
                postInfluenceLevel += 30;
            }

            int previouslyInfluencedUsersCount = 0;

            foreach (KeyValuePair <UserAdapter, int> userLikesPair in this.m_UsersSortedByLikes)
            {
                if (i_Post.LikedBy.Contains(userLikesPair.Key))
                {
                    previouslyInfluencedUsersCount++;
                }
            }

            // The more people who liked the post but never liked user's content before, the more credit the post gets, up to 50%
            if (previouslyInfluencedUsersCount > 0)
            {
                postInfluenceLevel += ((i_Post.LikedBy.Count - previouslyInfluencedUsersCount) / i_Post.LikedBy.Count) * 50;
            }
            else
            {
                postInfluenceLevel += 50;
            }

            // The more people who already liked user's content liked it, the more credit it gets, up to 20%
            if (i_Post.LikedBy.Count == 0)
            {
                postInfluenceLevel += 0;
            }
            else
            {
                postInfluenceLevel += (previouslyInfluencedUsersCount / i_Post.LikedBy.Count) * 20;
            }

            return(postInfluenceLevel);
        }
 public void SetAndPreviewPostToAnalyze(string i_PostMessage)
 {
     try
     {
         PostAdapter postToPreviewAndAnalyze = m_FetcherHolder.FetchSetCurrentPostToAnalyze(i_PostMessage, r_FormToPopulate.LoginResult.LoggedInUser);
         if (postToPreviewAndAnalyze == null)
         {
             r_FormToPopulate.DisplayErrorDialog("Couldn't find the post to preview");
         }
         else
         {
             PostToAnalyse = postToPreviewAndAnalyze;
             displayPostToPreview(postToPreviewAndAnalyze);
         }
     }
     catch (Exception e)
     {
         r_FormToPopulate.DisplayErrorDialog(string.Format("Something went wrong in previewing your post{1} Advanced:{0}", e.Message, Environment.NewLine));
     }
 }
Exemple #7
0
        private Dictionary <UserAdapter, int> aggregateUserLikes()
        {
            Dictionary <UserAdapter, int> m_usersLikesCount = new Dictionary <UserAdapter, int>();

            m_TotalNumberOfLikesRecievedInAllPosts = 0;

            SelectiveEnumarble <PostAdapter> filteredPosts = new SelectiveEnumarble <PostAdapter>(m_CurrentUserPostsCollection, CheckIfPostsLikedByGreaterThanZero);

            IEnumerator <PostAdapter> Iterator = filteredPosts.GetEnumerator();

            while (Iterator.MoveNext())
            {
                PostAdapter cur = Iterator.Current;
            }

            foreach (PostAdapter post in filteredPosts)
            {
                foreach (UserAdapter user in post.LikedBy)
                {
                    m_TotalNumberOfLikesRecievedInAllPosts++;
                    if (m_usersLikesCount.ContainsKey(user))
                    {
                        m_usersLikesCount[user]++;
                    }
                    else
                    {
                        m_usersLikesCount.Add(user, 1);
                    }
                }

                m_AvargeCountOfLikesPerPost += post.LikedBy.Count;
            }

            m_AvargeCountOfLikesPerPost /= m_CurrentUserPostsCollection.Count;
            return(m_usersLikesCount);
        }
Exemple #8
0
 public bool CheckIfPostsLikedByGreaterThanZero(PostAdapter i_Post)
 {
     return(i_Post == null ? false : i_Post.LikedBy.Count > 0);
 }
Exemple #9
0
 internal int GetPostInfluencePreserving(PostAdapter i_Post)
 {
     return((int)(quantitiveInfluencePreservationFactor(i_Post) * 70) + (int)(qualityInfluencePreservationFactor(i_Post) * 30));
 }
 public int GetPostInfluencePreserving(PostAdapter i_Post)
 {
     return(this.m_InfluenceAnalyser.GetPostInfluencePreserving(i_Post));
 }
 public int GetPostInfluenceLevel(PostAdapter i_Post)
 {
     return(this.m_InfluenceAnalyser.GetPostInfluenceLevel(i_Post));
 }
        public PostAdapter FetchSetCurrentPostToAnalyze(string i_PostMessage, UserAdapter i_User)
        {
            PostAdapter postToReturn = i_User.Posts.Find(x => x.Message == i_PostMessage);

            return(postToReturn);
        }