mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Simplifying the shit out of feed fetch histories.
This commit is contained in:
parent
84e6d1a4fb
commit
6e93972ada
2 changed files with 4 additions and 9 deletions
|
@ -52,7 +52,7 @@ class MStatistics(mongo.Document):
|
|||
if not last_day:
|
||||
last_day = datetime.datetime.now() - datetime.timedelta(hours=24)
|
||||
|
||||
feeds_fetched = MFeedFetchHistory.objects(fetch_date__gte=last_day).count()
|
||||
feeds_fetched = MFeedFetchHistory.count()
|
||||
cls.objects(key='feeds_fetched').update_one(upsert=True, key='feeds_fetched', value=feeds_fetched)
|
||||
|
||||
MFeedFetchHistory.objects(fetch_date__lt=last_day).delete()
|
||||
|
|
|
@ -13,16 +13,11 @@ graph_config = {
|
|||
}
|
||||
|
||||
def calculate_metrics():
|
||||
import datetime
|
||||
from apps.rss_feeds.models import MFeedFetchHistory, MPageFetchHistory
|
||||
|
||||
last_day = datetime.datetime.utcnow() - datetime.timedelta(days=1)
|
||||
from apps.statistics.models import MStatistics
|
||||
statistics = MStatistics.all()
|
||||
|
||||
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(),
|
||||
'feed_success': statistics['feeds_fetched']
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue