Skip to content

Commit

Permalink
change stats structure
Browse files Browse the repository at this point in the history
  • Loading branch information
perewall committed Oct 1, 2018
1 parent c1587c9 commit a125ae6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from werkzeug.exceptions import HTTPException


__version__ = '0.1.0'
__version__ = '0.1.1'

db = SQLAlchemy()
cache = Cache()
Expand Down
22 changes: 12 additions & 10 deletions app/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from flask import current_app

from . import db
from . import db, __version__
from .models import User, Resume


Expand Down Expand Up @@ -73,19 +73,21 @@ def stats(self):
redis = current_app.redis.info('memory')

result = {
'db': {
'rows': {'total': users + resume, 'max': 10000},
'memory': {'total': redis['used_memory'], 'max': 25000000}
'providers': [],
'health': {
'db': {'current': users + resume, 'max': 10000},
'cache': {'current': redis['used_memory'], 'max': 25000000}
},
'users': {'items': [], 'total': users},
'resume': {'items': [], 'total': resume}
'version': __version__
}

ResumeUser = Resume.query.join(User)
for prov in current_app.providers.keys():
result['users']['items'].append(
{prov: User.query.filter_by(provider=prov).count()})
result['resume']['items'].append(
{prov: ResumeUser.filter(User.provider == prov).count()})
provider = {
'name': prov,
'users': User.query.filter_by(provider=prov).count(),
'resume': ResumeUser.filter(User.provider == prov).count()
}
result['providers'].append(provider)

return result

0 comments on commit a125ae6

Please sign in to comment.