Esempio n. 1
0
def get_feed_info(feed_id):
    from rdr.modules.feeds.articles.status import UserPackageRecord

    feed = Feed.query.filter(Feed.id == feed_id).first()
    if not feed:
        raise NotFound("Feed not found")
    rec = UserPackageRecord.wrap_package(feed)
    return {"success": True, "feed": rec.to_dict()}
Esempio n. 2
0
def articles_sync(feed_id):
    page = 1
    feed = Feed.query.filter(Feed.id == feed_id).first()
    if not feed:
        raise json.InvalidRequest("Unknown feed id")
    default_update_pause_seconds = 300
    if not feed.last_update or (datetime.now() - feed.last_update) > timedelta(seconds=default_update_pause_seconds):
        synchronizer = ArticlesSynchronizer(feed)
        synchronizer.sync()
    articles_pagination = Article.query \
        .filter((Article.feed_id == feed_id) & (Article.active == True)) \
        .order_by(Article.published.desc()) \
        .options(db.joinedload(Article.feed)) \
        .paginate(page, per_page=40, error_out=False)

    records = UserArticleRecord.wrap_articles_list(articles_pagination.items)
    feed_record = UserPackageRecord.wrap_package(feed)

    return {
        'success': True,
        'articles': [x.to_dict() for x in records],
        'feed': feed_record.to_dict()
    }
Esempio n. 3
0
def articles_list(feed_id):
    page = 1
    if 'page' in request.args:
        page = int(request.args['page'])

    feed = Feed.query.filter(Feed.id == feed_id).first()
    if not feed:
        raise json.InvalidRequest("Unknown feed id")
    if not feed.active:
        activate_feed(feed)
    articles_pagination = Article.query \
        .filter((Article.feed_id == feed_id) & (Article.active == True)) \
        .order_by(Article.published.desc()) \
        .options(db.joinedload(Article.feed)) \
        .paginate(page, per_page=40, error_out=False)

    records = UserArticleRecord.wrap_articles_list(articles_pagination.items)
    feed_record = UserPackageRecord.wrap_package(feed)

    return {
        'success': True,
        'articles': [x.to_dict() for x in records],
        'feed': feed_record.to_dict()
    }