mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
33 lines
905 B
Python
33 lines
905 B
Python
![]() |
import datetime
|
||
|
|
||
|
from django.conf import settings
|
||
|
from django.http import JsonResponse
|
||
|
from django.views import View
|
||
|
|
||
|
class TasksPipeline(View):
|
||
|
|
||
|
def get(self, request):
|
||
|
return self.stats
|
||
|
|
||
|
@property
|
||
|
def stats(self):
|
||
|
|
||
|
stats = settings.MONGOANALYTICSDB.nbanalytics.feed_fetches.aggregate([{
|
||
|
"$match": {
|
||
|
"date": {
|
||
|
"$gt": datetime.datetime.now() - datetime.timedelta(minutes=5),
|
||
|
},
|
||
|
},
|
||
|
}, {
|
||
|
"$group": {
|
||
|
"_id": 1,
|
||
|
"feed_fetch": {"$avg": "$feed_fetch"},
|
||
|
"feed_process": {"$avg": "$feed_process"},
|
||
|
"page": {"$avg": "$page"},
|
||
|
"icon": {"$avg": "$icon"},
|
||
|
"total": {"$avg": "$total"},
|
||
|
},
|
||
|
}])
|
||
|
|
||
|
return list(stats)[0]
|