Skip to content

Commit

Permalink
Dashboard使用模板片段缓存替换view缓存 fix hhyo#552
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Nov 29, 2019
1 parent c4c7da7 commit 8b40615
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 143 deletions.
2 changes: 0 additions & 2 deletions common/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: UTF-8 -*-
from django.contrib.auth.decorators import permission_required
from django.shortcuts import render
from django.views.decorators.cache import cache_page

from sql.models import SqlWorkflow, QueryPrivilegesApply, Users, Instance

Expand All @@ -15,7 +14,6 @@
CurrentConfig.ONLINE_HOST = '/static/echarts/'


@cache_page(60 * 60)
@permission_required('sql.menu_dashboard', raise_exception=True)
def pyecharts(request):
"""dashboard view"""
Expand Down
286 changes: 145 additions & 141 deletions common/templates/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,171 +1,175 @@
{% extends "base.html" %}

{% load cache %}

{% block content %}
<!-- /.row -->
<div class="row">
<div class="col-lg-3 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-check fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.sql_wf_cnt }}</div>
<div>SQL上线工单</div>
{% cache 600 dashboard %}
<!-- /.row -->
<div class="row">
<div class="col-lg-3 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-check fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.sql_wf_cnt }}</div>
<div>SQL上线工单</div>
</div>
</div>
</div>
<a href="/sqlworkflow/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
<a href="/sqlworkflow/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-search fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.query_wf_cnt }}</div>
<div>SQL查询工单</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-search fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.query_wf_cnt }}</div>
<div>SQL查询工单</div>
</div>
</div>
</div>
<a href="/queryapplylist/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
<a href="/queryapplylist/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-yellow">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-user fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.user_cnt }}</div>
<div>平台用户</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-yellow">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-user fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.user_cnt }}</div>
<div>平台用户</div>
</div>
</div>
</div>
<a href="/admin/sql/users/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
<a href="/admin/sql/users/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-red">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-database fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.ins_cnt }}</div>
<div>实例数量</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-red">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-database fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">{{ count_stats.ins_cnt }}</div>
<div>实例数量</div>
</div>
</div>
</div>
<a href="/instance/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
<a href="/instance/">
<div class="panel-footer">
<span class="pull-left">更多</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-8">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL查询统计
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.line1|safe }}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL上线数量
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.bar1|safe }}
<!-- /.row -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL上线用户
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.bar2|safe }}
<!-- /.row -->
<div class="row">
<div class="col-lg-8">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL查询统计
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.line1|safe }}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-8 -->
<div class="col-lg-4">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL上线统计
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL上线数量
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.bar1|safe }}
<!-- /.row -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.pie1|safe }}
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL上线用户
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.bar2|safe }}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel-body -->
<!-- /.panel -->
</div>
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> DB检索行数
</div>
<div class="panel-body">
{{ chart.pie5|safe }}
<!-- /.col-lg-8 -->
<div class="col-lg-4">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL上线统计
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.pie1|safe }}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL查询用户
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> DB检索行数
</div>
<div class="panel-body">
{{ chart.pie5|safe }}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.pie4|safe }}
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> SQL查询用户
</div>
<!-- /.panel-heading -->
<div class="panel-body">
{{ chart.pie4|safe }}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel-body -->
<!-- /.panel .chat-panel -->
</div>
<!-- /.panel .chat-panel -->
<!-- /.col-lg-4 -->
</div>
<!-- /.col-lg-4 -->
</div>
<!-- /.row -->
<!-- /.row -->
{% endcache %}
{% endblock content %}

0 comments on commit 8b40615

Please sign in to comment.