1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-23 17:34:17 +03:00

updated stats_counters db to include interval_type for values

This commit is contained in:
Adolfo Gómez García 2022-11-02 21:38:01 +01:00
parent fc6224dada
commit 396e0f0c38
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 15 additions and 1 deletions

View File

@ -2,6 +2,7 @@
from django.db import migrations, models
import django.db.models.deletion
import uds.models.stats_counters
class Migration(migrations.Migration):
@ -38,6 +39,11 @@ class Migration(migrations.Migration):
name='mfa',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='authenticators', to='uds.mfa'),
),
migrations.AddField(
model_name='statscounters',
name='interval_type',
field=models.SmallIntegerField(db_index=True, default=uds.models.stats_counters.StatsCounters.CounterIntervalType['NONE']),
),
migrations.RemoveIndex(
model_name='statscounters',
name='uds_stats_c_owner_t_db894d_idx',

View File

@ -31,7 +31,7 @@
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
"""
import typing
import types
import enum
import datetime
import logging
@ -49,11 +49,19 @@ class StatsCounters(models.Model):
"""
Statistics about counters (number of users at a given time, number of services at a time, whatever...)
"""
# Valid intervals types for counters data
class CounterIntervalType(enum.IntEnum):
NONE = 0
MINUTE = 1
HOUR = 2
DAY = 3
WEEK = 4
owner_id = models.IntegerField(db_index=True, default=0)
owner_type = models.SmallIntegerField(db_index=True, default=0)
counter_type = models.SmallIntegerField(db_index=True, default=0)
stamp = models.IntegerField(db_index=True, default=0)
interval_type = models.SmallIntegerField(db_index=True, default=CounterIntervalType.NONE)
value = models.IntegerField(db_index=True, default=0)
# "fake" declarations for type checking