<commit_before>
Template.news.onRendered(function() {
  updateRSS('http://amherststudent.amherst.edu/?q=rss.xml');
});

Template.news.helpers({

  articles : function() {
    //pull the list of rss feeds for the user
    //forall rss, update database if need
    //return the users feeds from database

    //we update the rssData everytime the user rquests a feed

    var all = Rss.find().fetch();
    console.log("now you have ...")
    console.log(all)
    console.log(Rss.find().count())
    return all;
  }
});

var updateRSS = function (sourceRSS){
  var results=[];
  var rssAll = $.jGFeed(sourceRSS,
    function(feeds){
      if(!feeds){
       console.error("error: bad rss feed");
       return false;
      }
      for(var i=0; i<feeds.entries.length; i++){
        currentTitle = feeds.entries[i].title;
        if(!Rss.findOne({title:currentTitle})){
          //console.log(!Rss.findOne({title:currentTitle}))
          //console.log(Rss.findOne({title:currentTitle}))
          console.log("found a new article, adding to database: "+currentTitle);
          Rss.insert(feeds.entries[i]);
        }
      }
    }, 10);
}

Template.article.helpers({
  title : function() { console.log(this); return this.title },
  link : function() { return this.link }
  
});<commit_msg>multiple sources work<commit_after>
Template.news.onRendered(function() {
  updateRSS('http://amherststudent.amherst.edu/?q=rss.xml');
  updateRSS('http://news.yale.edu/news-rss');

});


Template.news.helpers({

  articles : function() {
    //pull the list of rss feeds for the user
    //forall rss, update database if need
    //return the users feeds from database

    //we update the rssData everytime the user rquests a feed

    var all = Rss.find().fetch();
    console.log("now you have ...")
    console.log(all)
    console.log(Rss.find().count())
    return all;
  }
});

var updateRSS = function (sourceRSS){
  var results=[];
  var rssAll = $.jGFeed(sourceRSS,
    function(feeds){
      if(!feeds){
       console.error("error: bad rss feed");
       return false;
      }
      for(var i=0; i<feeds.entries.length; i++){
        currentTitle = feeds.entries[i].title;
        if(!Rss.findOne({title:currentTitle})){
          //console.log(!Rss.findOne({title:currentTitle}))
          //console.log(Rss.findOne({title:currentTitle}))
          console.log("found a new article, adding to database: "+currentTitle);
          Rss.insert(feeds.entries[i]);
        }
      }
    }, 5);
}

Template.article.helpers({
  title : function() { console.log(this); return this.title },
  link : function() { return this.link }

});
{'fraction_non_alphanumeric': 0.1582350703689616, 'fraction_numerical': 0.001901863826550019, 'mean_word_length': 2.8563049853372435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2098007', 'n_tokens_mistral': 862, 'n_tokens_neox': 845, 'n_words': 189}