Ejemplo n.º 1
0
        public static void ComputePublicVoteSums(long articleId, List<ProviderArticleVote> voteList)
        {
            double change = 0.0;
            ProviderArticleScore aScore = new ProviderArticleScore();
            aScore.LoadOrCreate(articleId, ProviderArticleScore.ScoreTypeEnum.PublicVoteSum, 0.0);
            change = PublicVoteSum(voteList);
            aScore.Score += change;
            aScore.Save();

            _log.Info("Public Vote sum Score - " + String.Format("{0:f}", aScore.Score) + " score / "
                                + String.Format("{0:f}", change) + " change / "
                                + voteList.Count + " votes");
        }
Ejemplo n.º 2
0
        public static void ComputeCommentSum(long articleId)
        {
            ProviderArticleScore aScore = new ProviderArticleScore();
            aScore.LoadOrCreate(articleId, ProviderArticleScore.ScoreTypeEnum.CommentSum, 0.0);
            List<ProviderConversation> conversationList = ProviderConversation.LoadByArticleId(articleId);
            if(conversationList.Count == 0)
            {
                aScore.Score = 0;
            }
            else
            {
                aScore.Score = conversationList.Sum(aConversation => aConversation.CommentCount);
            }
            aScore.Save();

            _log.Info("Comment Sum Score - " + String.Format("{0:f}", aScore.Score) + " score");
        }
Ejemplo n.º 3
0
        public static void ComputeSparrowScores(long articleId, List<ProviderArticleVote> voteList)
        {
            ProviderArticleVote aVote = voteList[0];
            if (!MovingAverage.IsValidDate(aVote.ArticleSystemCreateDate))
            {
                _log.Info("Votes for article id " + articleId + " ignored; Passed date");
            }
            else
            {
                double weight = 0.0;
                double change = 0.0;
                ProviderArticleScore aScore = new ProviderArticleScore();
                aScore.LoadOrCreate(articleId, ProviderArticleScore.ScoreTypeEnum.SparrowRank, 1.0);
                weight = MovingAverage.CumWeight(aVote.ArticleSystemCreateDate, aScore.SystemEditDate, DateTime.UtcNow);
                change = (aScore.Score * (1 - weight)) + MovingAverage.CumWeight(aVote.ArticleSystemCreateDate) * SparrowSum(voteList);
                aScore.Score += change;
                aScore.Save();

                _log.Info("Sparrow Score - " + String.Format("{0:f}", aScore.Score) + " score / "
                                    + String.Format("{0:f}", change) + " change / "
                                    + voteList.Count + " votes / "
                                    + weight + " weight");
            }
        }