Ejemplo n.º 1
0
	def vetoFeed(self, user, session_token, feed, delete_news = False):
		feed.veto = True
		feed_loader = DBFeedLoader()
		feed_loader.setCredentials(user, session_token)
		
		feed_loader.save(feed)
		
		if delete_news:
			artloader = DBArticleLoader()
			fts_artloader = FTSArticleLoader(xapian_news_base)
			fts_artloader.deleteArticlesFromFeed(feed, artloader)
			artloader.setCredentials(user, session_token)
			artloader.deleteArticlesFromFeed(feed)
Ejemplo n.º 2
0
	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)
Ejemplo n.º 3
0
	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)