Beispiel #1
0
func (fm *FeedManager) scoreFeedContent(f content.Feed) {
	if f == nil {
		fm.logger.Infoln("No feed provided")
		return
	}

	data := f.Data()

	if len(fm.config.Popularity.Providers) == 0 {
		fm.logger.Infoln("No popularity providers configured")
		return
	}

	if !fm.activeFeeds[data.Id] {
		fm.logger.Infof("Feed '%s' no longer active for scoring\n", f)
		return
	}

	fm.logger.Infoln("Scoring feed content for " + f.String())

	articles := f.LatestArticles()
	if f.HasErr() {
		fm.logger.Printf("Error getting latest feed articles for '%s': %v\n", f, f.Err())
		return
	}

	for i := range articles {
		sa := fm.repo.Article()
		sa.Data(articles[i].Data())
		fm.scoreArticle <- sa
	}

	fm.logger.Infoln("Done scoring feed content for " + f.String())

	select {
	case <-time.After(30 * time.Minute):
		go fm.scoreFeedContent(f)
	case <-fm.done:
		return
	}
}