mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
32 lines
905 B
Python
Executable file
32 lines
905 B
Python
Executable file
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]
|