change the general stats: display #alias, forward, reply, block
This commit is contained in:
parent
23c17b8cff
commit
01cc07b9fe
|
@ -22,51 +22,35 @@
|
||||||
{% block default_content %}
|
{% block default_content %}
|
||||||
<!-- Global Stats -->
|
<!-- Global Stats -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6 col-sm-4 col-lg-2">
|
<div class="col-6 col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body p-3 text-center">
|
<div class="card-body p-3 text-center">
|
||||||
<div class="h1 m-0 mt-3">{{ stats.nb_alias }}</div>
|
<div class="h1 m-0">{{ stats.nb_alias }}</div>
|
||||||
<div class="text-muted mb-4">Aliases</div>
|
<div class="text-muted">Aliases</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 col-sm-4 col-lg-2">
|
<div class="col-6 col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body p-3 text-center">
|
<div class="card-body p-3 text-center">
|
||||||
<div class="h1 m-0 mt-3">{{ stats.nb_active_alias }}</div>
|
<div class="h1 m-0">{{ stats.nb_forward }}</div>
|
||||||
<div class="text-muted mb-4">Active Aliases</div>
|
<div class="text-muted">Forwards</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 col-sm-4 col-lg-2">
|
<div class="col-6 col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body p-3 text-center">
|
<div class="card-body p-3 text-center">
|
||||||
<div class="h1 m-0 mt-3">{{ stats.nb_forward }}</div>
|
<div class="h1 m-0">{{ stats.nb_reply }}</div>
|
||||||
<div class="text-muted mb-4">Forwards</div>
|
<div class="text-muted">Replies</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 col-sm-4 col-lg-2">
|
<div class="col-6 col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body p-3 text-center">
|
<div class="card-body p-3 text-center">
|
||||||
<div class="h1 m-0 mt-3">{{ stats.nb_reply }}</div>
|
<div class="h1 m-0">{{ stats.nb_block }}</div>
|
||||||
<div class="text-muted mb-4">Replies</div>
|
<div class="text-muted">Blocks</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-sm-4 col-lg-2">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body p-3 text-center">
|
|
||||||
<div class="h1 m-0 mt-3">{{ stats.nb_directory }}</div>
|
|
||||||
<div class="text-muted mb-4">Directories</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-sm-4 col-lg-2">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body p-3 text-center">
|
|
||||||
<div class="h1 m-0 mt-3">{{ stats.nb_domain }}</div>
|
|
||||||
<div class="text-muted mb-4">Domains</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,33 +24,26 @@ from app.models import (
|
||||||
@dataclass
|
@dataclass
|
||||||
class Stats:
|
class Stats:
|
||||||
nb_alias: int
|
nb_alias: int
|
||||||
nb_active_alias: int
|
|
||||||
nb_forward: int
|
nb_forward: int
|
||||||
nb_reply: int
|
nb_reply: int
|
||||||
nb_domain: int
|
nb_block: int
|
||||||
nb_directory: int
|
|
||||||
|
|
||||||
|
|
||||||
def get_stats(user: User) -> Stats:
|
def get_stats(user: User) -> Stats:
|
||||||
nb_alias = Alias.query.filter_by(user_id=user.id).count()
|
nb_alias = Alias.query.filter_by(user_id=user.id).count()
|
||||||
nb_active_alias = Alias.query.filter_by(user_id=user.id, enabled=True).count()
|
|
||||||
nb_forward = EmailLog.query.filter_by(
|
nb_forward = EmailLog.query.filter_by(
|
||||||
user_id=user.id, is_reply=False, blocked=False, bounced=False
|
user_id=user.id, is_reply=False, blocked=False, bounced=False
|
||||||
).count()
|
).count()
|
||||||
nb_reply = EmailLog.query.filter_by(
|
nb_reply = EmailLog.query.filter_by(
|
||||||
user_id=user.id, is_reply=True, blocked=False, bounced=False
|
user_id=user.id, is_reply=True, blocked=False, bounced=False
|
||||||
).count()
|
).count()
|
||||||
nb_domain = CustomDomain.query.filter_by(user_id=user.id).count()
|
nb_block = EmailLog.query.filter_by(
|
||||||
nb_directory = Directory.query.filter_by(user_id=user.id).count()
|
user_id=user.id, is_reply=False, blocked=True, bounced=False
|
||||||
|
).count()
|
||||||
|
|
||||||
data = locals()
|
return Stats(
|
||||||
# to keep only Stats field
|
nb_alias=nb_alias, nb_forward=nb_forward, nb_reply=nb_reply, nb_block=nb_block
|
||||||
data = {
|
)
|
||||||
k: v
|
|
||||||
for (k, v) in data.items()
|
|
||||||
if k in vars(Stats)["__dataclass_fields__"].keys()
|
|
||||||
}
|
|
||||||
return Stats(**data)
|
|
||||||
|
|
||||||
|
|
||||||
@dashboard_bp.route("/", methods=["GET", "POST"])
|
@dashboard_bp.route("/", methods=["GET", "POST"])
|
||||||
|
|
Loading…
Reference in a new issue