Beispiel #1
0
        public IActionResult UpdateProposeSongs()
        {
            using (var db = new SongRecommendContext()) {
                var count = 0;
                foreach (var song in db.ProposeSong)
                {
                    //---------------------------
                    // 좋아요 가져오기
                    //---------------------------
                    HttpClient client     = new HttpClient();
                    var        jsonString = client.GetStringAsync($"https://www.melon.com/commonlike/getSongLike.json?contsIds={song.SongId}").Result;
                    var        like       = 0;
                    try {
                        like = JObject.Parse(jsonString).Value <IEnumerable <JToken> >("contsLike").First().Value <int>("SUMMCNT");
                    }
                    catch { }

                    song.Like = like;
                    song.Rate = AnalyzeRateSvc.Execute(song.Lyric).Rate;
                    count++;
                }

                db.SaveChanges();
                return(Ok(count));
            }
        }
Beispiel #2
0
 public IActionResult CalcSongsRate()
 {
     using (var db = new SongRecommendContext()) {
         foreach (var song in db.ProposeSong)
         {
             song.Rate = AnalyzeRateSvc.Execute(song.Lyric).Rate;
         }
         db.SaveChanges();
         return(Ok());
     }
 }
Beispiel #3
0
        public IActionResult CalcWordsRate()
        {
            using (var db = new SongRecommendContext()) {
                var totalPositive = db.BaseWord.Sum(x => x.PositivePoint * 100);
                var totalNegative = db.BaseWord.Sum(x => x.NegativePoint * 100);

                foreach (var word in db.BaseWord)
                {
                    word.Rate = AnalyzeRateSvc.GetAdjustedRate(word.PositivePoint * 100, word.NegativePoint * 100, totalPositive, totalNegative);
                }

                db.SaveChanges();
                return(Ok());
            }
        }