示例#1
0
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')
示例#2
0
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('/')
示例#3
0
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('/')
示例#4
0
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')
示例#5
0
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)
示例#6
0
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)
示例#7
0
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)
示例#8
0
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)