Exemple #1
0
def get_content_from_duration(duration, thematics=None, user_id=None):
	words      = utils.how_many_words(int(duration))
	thematics  = thematics.split(',') if thematics else None
	articles   = {
		"one"   : Article.get_closest(count_words=words,   limit=5, thematics=thematics, user=user_id), # FIXME
		"two"   : Article.get_closest(count_words=words/2, limit=2, thematics=thematics, user=user_id),
		"three" : Article.get_closest(count_words=words/3, limit=3, thematics=thematics, user=user_id),
	}
	return dumps({'articles': articles, 'delta': duration})
Exemple #2
0
def get_content_from_itineraire(src, tgt, thematics=None, user_id=None):
	itineraire = utils.get_itineraire(src, tgt)
	duration   = itineraire['delta']
	words      = utils.how_many_words(duration)
	thematics  = thematics.split(',') if thematics else None
	articles   = {
		"one"   : Article.get_closest(count_words=words,   limit=5, thematics=thematics, user=user_id), # FIXME
		"two"   : Article.get_closest(count_words=words/2, limit=2, thematics=thematics, user=user_id),
		"three" : Article.get_closest(count_words=words/3, limit=3, thematics=thematics, user=user_id),
	}
	itineraire["articles"] = articles
	return dumps(itineraire)