add subdomain and directory stats to Metric

This commit is contained in:
Son 2021-11-17 17:43:59 +01:00
parent ffc04c7fe9
commit bccfcee780
3 changed files with 52 additions and 0 deletions

View File

@ -2593,6 +2593,11 @@ class Metric2(Base, ModelMixin):
nb_total_bounced_last_24h = sa.Column(sa.Float, nullable=True)
nb_verified_custom_domain = sa.Column(sa.Float, nullable=True)
nb_subdomain = sa.Column(sa.Float, nullable=True)
nb_directory = sa.Column(sa.Float, nullable=True)
nb_deleted_directory = sa.Column(sa.Float, nullable=True)
nb_deleted_subdomain = sa.Column(sa.Float, nullable=True)
nb_app = sa.Column(sa.Float, nullable=True)

12
cron.py
View File

@ -57,6 +57,9 @@ from app.models import (
DomainDeletedAlias,
Hibp,
HibpNotifiedAlias,
Directory,
DeletedDirectory,
DeletedSubdomain,
)
from app.utils import sanitize_email
from server import create_light_app
@ -292,6 +295,10 @@ def compute_metric2() -> Metric2:
.count(),
# other stats
nb_verified_custom_domain=CustomDomain.filter_by(verified=True).count(),
nb_subdomain=CustomDomain.filter_by(is_sl_subdomain=True).count(),
nb_directory=Directory.count(),
nb_deleted_directory=DeletedDirectory.count(),
nb_deleted_subdomain=DeletedSubdomain.count(),
nb_app=Client.count(),
commit=True,
)
@ -482,6 +489,11 @@ nb_bounced_last_24h: {stats_today.nb_bounced_last_24h} - {increase_percent(stats
nb_total_bounced_last_24h: {stats_today.nb_total_bounced_last_24h} - {increase_percent(stats_yesterday.nb_total_bounced_last_24h, stats_today.nb_total_bounced_last_24h)}
nb_custom_domain: {stats_today.nb_verified_custom_domain} - {increase_percent(stats_yesterday.nb_verified_custom_domain, stats_today.nb_verified_custom_domain)}
nb_subdomain: {stats_today.nb_subdomain} - {increase_percent(stats_yesterday.nb_subdomain, stats_today.nb_subdomain)}
nb_directory: {stats_today.nb_directory} - {increase_percent(stats_yesterday.nb_directory, stats_today.nb_directory)}
nb_deleted_directory: {stats_today.nb_deleted_directory} - {increase_percent(stats_yesterday.nb_deleted_directory, stats_today.nb_deleted_directory)}
nb_deleted_subdomain: {stats_today.nb_deleted_subdomain} - {increase_percent(stats_yesterday.nb_deleted_subdomain, stats_today.nb_deleted_subdomain)}
nb_app: {stats_today.nb_app} - {increase_percent(stats_yesterday.nb_app, stats_today.nb_app)}
nb_referred_user: {stats_today.nb_referred_user} - {increase_percent(stats_yesterday.nb_referred_user, stats_today.nb_referred_user)}
nb_referred_user_upgrade: {stats_today.nb_referred_user_paid} - {increase_percent(stats_yesterday.nb_referred_user_paid, stats_today.nb_referred_user_paid)}

View File

@ -0,0 +1,35 @@
"""empty message
Revision ID: 9031c9e28510
Revises: e6e8e12f5a13
Create Date: 2021-11-17 17:43:21.425167
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9031c9e28510'
down_revision = 'e6e8e12f5a13'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('metric2', sa.Column('nb_deleted_directory', sa.Float(), nullable=True))
op.add_column('metric2', sa.Column('nb_deleted_subdomain', sa.Float(), nullable=True))
op.add_column('metric2', sa.Column('nb_directory', sa.Float(), nullable=True))
op.add_column('metric2', sa.Column('nb_subdomain', sa.Float(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('metric2', 'nb_subdomain')
op.drop_column('metric2', 'nb_directory')
op.drop_column('metric2', 'nb_deleted_subdomain')
op.drop_column('metric2', 'nb_deleted_directory')
# ### end Alembic commands ###