当前位置: 首页>>代码示例>>Python>>正文


Python Article.query方法代码示例

本文整理汇总了Python中model.Article.query方法的典型用法代码示例。如果您正苦于以下问题:Python Article.query方法的具体用法?Python Article.query怎么用?Python Article.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Article的用法示例。


在下文中一共展示了Article.query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_articles

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import query [as 别名]
def get_articles(count=10, force=False):
    max_time = datetime.datetime.now() if force else datetime.datetime.now() - datetime.timedelta(hours=1)
    q = Article.query(Article.ml_service_time <= max_time, Article.ml_service_time != None).order(-Article.ml_service_time)
    articles = q.fetch(count)
    for a in articles:
        a.ml_service_time = datetime.datetime.now()
    ndb.put_multi(articles)
    return articles
开发者ID:nate-parrott,项目名称:fast-news,代码行数:10,代码来源:ml.py

示例2: post

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import query [as 别名]
 def post(self):
     url = canonical_url(self.request.get('url'))
     source_id = Source.id_for_source(url)
     source = ndb.Key(Source, source_id).get()
     while True:
         articles = Article.query(Article.source == source.key).order(-Article.added_date, Article.added_order).fetch(limit=100, keys_only=True)
         if len(articles) == 0: break
         ndb.delete_multi(articles)
     source.key.delete()
     self.response.write('Done')
开发者ID:nate-parrott,项目名称:fast-news,代码行数:12,代码来源:admin.py

示例3: backfill_articles_for_ml

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import query [as 别名]
def backfill_articles_for_ml():
    count = 500
    put_batch = []
    for article in Article.query().order(-Article.added_date).iter(count):
        if not article.ml_service_time and not article.processed_by_ml_service:
            article.ml_service_time = util.datetime_from_timestamp(0)
            put_batch.append(article)
        if len(put_batch) > 50:
            ndb.put_multi(put_batch)
            put_batch = []
    if len(put_batch): ndb.put_multi(put_batch)
开发者ID:nate-parrott,项目名称:fast-news,代码行数:13,代码来源:ml.py

示例4: dump_items

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import query [as 别名]
def dump_items(cursor=None):
    q = Article.query().order(Article._key)
    count = 100
    if cursor:
        articles, next_cursor, has_more = q.fetch_page(count, start_cursor=Cursor(urlsafe=cursor))
    else:
        articles, next_cursor, has_more = q.fetch_page(count)
    return {
        "articles": [article.json(include_article_json=True) for article in articles if article.content != None],
        "cursor": next_cursor.urlsafe() if next_cursor else None,
        "has_more": has_more,
    }
开发者ID:nate-parrott,项目名称:fast-news,代码行数:14,代码来源:dump.py

示例5: stats

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import query [as 别名]
def stats():
    article_count = Article.query(Article.content != None).count(keys_only=True)
    return {"article_count": article_count}
开发者ID:nate-parrott,项目名称:fast-news,代码行数:5,代码来源:dump.py


注:本文中的model.Article.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。