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


Python MFeedFetchHistory.objects方法代码示例

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


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

示例1: calculate_metrics

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
def calculate_metrics():
    import datetime
    from apps.rss_feeds.models import MFeedFetchHistory, MPageFetchHistory
    
    last_day = datetime.datetime.utcnow() - datetime.timedelta(days=1)
    
    return {
        'feed_errors': MFeedFetchHistory.objects(fetch_date__gte=last_day, status_code__nin=[200, 304]).count(),
        'feed_success': MFeedFetchHistory.objects(fetch_date__gte=last_day, status_code__in=[200, 304]).count(),
        'page_errors': MPageFetchHistory.objects(fetch_date__gte=last_day, status_code__nin=[200, 304]).count(),
        'page_success': MPageFetchHistory.objects(fetch_date__gte=last_day, status_code__in=[200, 304]).count(),
    }
开发者ID:AnushPrem,项目名称:NewsBlur,代码行数:14,代码来源:newsblur_errors.py

示例2: collect_statistics_feeds_fetched

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
 def collect_statistics_feeds_fetched(cls, last_day=None):
     if not last_day:
         last_day = datetime.datetime.now() - datetime.timedelta(hours=24)
     
     feeds_fetched = MFeedFetchHistory.objects(fetch_date__gte=last_day).count()
     cls.objects(key='feeds_fetched').update_one(upsert=True, key='feeds_fetched', value=feeds_fetched)
     
     old_fetch_histories = MFeedFetchHistory.objects(fetch_date__lte=last_day)
     for history in old_fetch_histories:
         history.delete()
     old_page_histories = MPageFetchHistory.objects(fetch_date__lte=last_day)
     for history in old_page_histories:
         history.delete()
     
     return feeds_fetched
开发者ID:aparo,项目名称:NewsBlur,代码行数:17,代码来源:models.py

示例3: collect_statistics_feeds_fetched

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
    def collect_statistics_feeds_fetched(cls, last_day=None):
        if not last_day:
            last_day = datetime.datetime.now() - datetime.timedelta(hours=24)

        feeds_fetched = MFeedFetchHistory.objects(fetch_date__gte=last_day).count()
        cls.objects(key="feeds_fetched").update_one(upsert=True, key="feeds_fetched", value=feeds_fetched)

        return feeds_fetched
开发者ID:adamjernst,项目名称:NewsBlur,代码行数:10,代码来源:models.py

示例4: delete_old_history

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
 def delete_old_history():
     print "Deleting old history."
     feed_fetch_last_day = MFeedFetchHistory.objects(fetch_date__lt=last_day, status_code__in=[200, 304])
     page_fetch_last_day = MPageFetchHistory.objects(fetch_date__lt=last_day, status_code__in=[200, 304])
     feed_fetch_last_month = MFeedFetchHistory.objects(fetch_date__lt=last_month)
     page_fetch_last_month = MPageFetchHistory.objects(fetch_date__lt=last_month)
     push_last_month = MFeedPushHistory.objects(push_date__lt=last_month)
     print "Found %s/%s/%s/%s/%s (feed/page day, feed/page month, push month)" % (
         feed_fetch_last_day.count(),
         page_fetch_last_day.count(),
         feed_fetch_last_month.count(),
         page_fetch_last_month.count(),
         push_last_month.count(),
     )
     
     feed_fetch_last_day.delete()
     page_fetch_last_day.delete()
     feed_fetch_last_month.delete()
     page_fetch_last_month.delete()
     push_last_month.delete()
开发者ID:happyda,项目名称:NewsBlur,代码行数:22,代码来源:models.py

示例5: MuninGraph

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
#!/usr/bin/env python 

from utils.munin.base import MuninGraph
from apps.rss_feeds.models import MFeedFetchHistory, MPageFetchHistory
import datetime


graph_config = {
    'graph_category' : 'NewsBlur',
    'graph_title' : 'NewsBlur Fetching History',
    'graph_vlabel' : 'errors',
    'feed_errors.label': 'Feed Errors',
    'feed_success.label': 'Feed Success',
    'page_errors.label': 'Page Errors',
    'page_success.label': 'Page Success',
}

last_day = datetime.datetime.utcnow() - datetime.timedelta(days=1)

metrics = {
    'feed_errors': MFeedFetchHistory.objects(fetch_date__gte=last_day, status_code__nin=[200, 304]).count(),
    'feed_success': MFeedFetchHistory.objects(fetch_date__gte=last_day, status_code__in=[200, 304]).count(),
    'page_errors': MPageFetchHistory.objects(fetch_date__gte=last_day, status_code__nin=[200, 304]).count(),
    'page_success': MPageFetchHistory.objects(fetch_date__gte=last_day, status_code__in=[200, 304]).count(),
}

if __name__ == '__main__':
    MuninGraph(graph_config, metrics).run()
开发者ID:francois2metz,项目名称:NewsBlur,代码行数:30,代码来源:newsblur_errors.py

示例6: delete_old_history

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
 def delete_old_history():
     MFeedFetchHistory.objects(fetch_date__lt=last_day, status_code__in=[200, 304]).delete()
     MPageFetchHistory.objects(fetch_date__lt=last_day, status_code__in=[200, 304]).delete()
     MFeedFetchHistory.objects(fetch_date__lt=last_month).delete()
     MPageFetchHistory.objects(fetch_date__lt=last_month).delete()
     MFeedPushHistory.objects(push_date__lt=last_month).delete()
开发者ID:imageoptimiser,项目名称:NewsBlur,代码行数:8,代码来源:models.py

示例7: delete_old_history

# 需要导入模块: from apps.rss_feeds.models import MFeedFetchHistory [as 别名]
# 或者: from apps.rss_feeds.models.MFeedFetchHistory import objects [as 别名]
 def delete_old_history():
     MFeedFetchHistory.objects(fetch_date__lt=last_day).delete()
     MPageFetchHistory.objects(fetch_date__lt=last_day).delete()
开发者ID:maheshbabu,项目名称:NewsBlur,代码行数:5,代码来源:models.py


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