當前位置: 首頁>>代碼示例>>Python>>正文


Python MPageFetchHistory.objects方法代碼示例

本文整理匯總了Python中apps.rss_feeds.models.MPageFetchHistory.objects方法的典型用法代碼示例。如果您正苦於以下問題:Python MPageFetchHistory.objects方法的具體用法?Python MPageFetchHistory.objects怎麽用?Python MPageFetchHistory.objects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apps.rss_feeds.models.MPageFetchHistory的用法示例。


在下文中一共展示了MPageFetchHistory.objects方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: calculate_metrics

# 需要導入模塊: from apps.rss_feeds.models import MPageFetchHistory [as 別名]
# 或者: from apps.rss_feeds.models.MPageFetchHistory 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: delete_old_history

# 需要導入模塊: from apps.rss_feeds.models import MPageFetchHistory [as 別名]
# 或者: from apps.rss_feeds.models.MPageFetchHistory 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

示例3: collect_statistics_feeds_fetched

# 需要導入模塊: from apps.rss_feeds.models import MPageFetchHistory [as 別名]
# 或者: from apps.rss_feeds.models.MPageFetchHistory 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

示例4: MuninGraph

# 需要導入模塊: from apps.rss_feeds.models import MPageFetchHistory [as 別名]
# 或者: from apps.rss_feeds.models.MPageFetchHistory 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

示例5: delete_old_history

# 需要導入模塊: from apps.rss_feeds.models import MPageFetchHistory [as 別名]
# 或者: from apps.rss_feeds.models.MPageFetchHistory 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

示例6: delete_old_history

# 需要導入模塊: from apps.rss_feeds.models import MPageFetchHistory [as 別名]
# 或者: from apps.rss_feeds.models.MPageFetchHistory 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.MPageFetchHistory.objects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。