homes.py 720 B

1234567891011121314151617181920212223242526
  1. from apps.account.models import User
  2. from apps.assets.models import Host
  3. from apps.schedule.models import Job
  4. from apps.deploy.models import App
  5. from flask import Blueprint
  6. from libs.decorators import require_permission
  7. from libs.tools import json_response
  8. blueprint = Blueprint(__name__, __name__)
  9. @blueprint.route('/', methods=['GET'])
  10. @require_permission('home_view')
  11. def get():
  12. user_total = User.query.count()
  13. host_total = Host.query.count()
  14. job_total = Job.query.count()
  15. app_total = App.query.count()
  16. data = {'user_total': user_total,
  17. 'host_total': host_total,
  18. 'job_total': job_total,
  19. 'app_total': app_total,
  20. }
  21. return json_response(data)