mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
29 lines
No EOL
776 B
Python
Executable file
29 lines
No EOL
776 B
Python
Executable file
import datetime
|
|
from django.conf import settings
|
|
from django.http import JsonResponse
|
|
from django.views import View
|
|
|
|
class TasksCodes(View):
|
|
|
|
def get(self, request):
|
|
servers = dict((("_%s" % s['_id'], s['feeds']) for s in self.stats))
|
|
|
|
return JsonResponse(servers)
|
|
|
|
@property
|
|
def stats(self):
|
|
stats = settings.MONGOANALYTICSDB.nbanalytics.feed_fetches.aggregate([{
|
|
"$match": {
|
|
"date": {
|
|
"$gt": datetime.datetime.now() - datetime.timedelta(minutes=5),
|
|
},
|
|
},
|
|
}, {
|
|
"$group": {
|
|
"_id" : "$feed_code",
|
|
"feeds" : {"$sum": 1},
|
|
},
|
|
}])
|
|
|
|
return list(stats)
|
|
|