def update_relevant(): """Updates relevant feeds""" print("Update relevant!") remove_current() entries_sorted = get_relevant_news(FEED, NUMBER_OF_KEYWORDS, ALGORITHM) entries_sorted = sorted(entries_sorted, key=lambda e: e['score'], reverse=True) save_current(entries_sorted) return redirect('/relevant')
def update_newest(): """Updates newest feeds""" print("Update newest!") remove_current() entries_sorted = get_feed_posts(FEED, NUMBER_OF_KEYWORDS) entries_sorted = sorted(entries_sorted, key=lambda e: e['published'], reverse=True) save_current(entries_sorted) return redirect('/')
def index(page): print("Without ML!") entries_sorted = get_saved_current(PER_PAGE, page) if not entries_sorted: entries_sorted = get_feed_posts(FEED, NUMBER_OF_KEYWORDS) save_current(entries_sorted) entries_sorted = entries_sorted[PER_PAGE * (page - 1): PER_PAGE * page] count = count_current() or len(entries_sorted) data = { 'entries': entries_sorted, 'count': count, 'view_name': 'index', } pagination = Pagination(page, PER_PAGE, count) return render_template('index.html', pagination=pagination, **data)
def index_relevant(page): print("ML is ON!") entries_sorted = get_saved_current(PER_PAGE, page) if not entries_sorted: entries_sorted = get_relevant_news(FEED, NUMBER_OF_KEYWORDS, ALGORITHM) entries_sorted = sorted(entries_sorted, key=lambda e: e['score'], reverse=True) save_current(entries_sorted) entries_sorted = entries_sorted[PER_PAGE * (page - 1): PER_PAGE * page] count = count_current() or len(entries_sorted) data = { 'entries': entries_sorted, 'count': count, 'view_name': 'relevant', } pagination = Pagination(page, PER_PAGE, count) return render_template('index.html', pagination=pagination, **data)