def rebuildFTSIndex(self, user, session_token): fts_index_mapper = FTSArticleLoader(xapian_news_base) fts_index_mapper.setStopWords(stopwords) database_mapper = DBArticleLoader() fts_index_mapper.cleanAll() page = 0 articles = database_mapper.loadAllArticles(page, 500) while len(articles) > 0: print "PAGE", page, "OFFSET", page*500 print "------------------" for a in articles: fts_index_mapper.save(a) fts_index_mapper.flush() page +=1 articles = database_mapper.loadAllArticles(page, 500)
def gatherNews(self, user, session_token, how_many = None, show_details = False): loader = DBFeedLoader() #seleccion de los feeds a consultar feeds = None if how_many: if how_many != 0: feeds = loader.randomSelect(how_many) else: feeds = loader.getAll() else: feeds = loader.randomSelect() fts_index_mapper = FTSArticleLoader(xapian_news_base) fts_index_mapper.setStopWords(stopwords) database_mapper = DBArticleLoader() database_mapper.setCredentials(user, session_token) for feed in feeds: feed.update(fts_index_mapper, database_mapper, show_details)