mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-20 06:50:23 +03:00
Merge remote-tracking branch 'origin/v4.0'
This commit is contained in:
commit
6424ca37cf
@ -145,7 +145,7 @@ class StatsManager(metaclass=singleton.Singleton):
|
||||
owners_ids: Ids of the owners to get counters from. If None, all owners will be used
|
||||
since: date from what to obtain counters. Unlimited if not specified
|
||||
to: date until obtain counters. Unlimited if not specified
|
||||
interval: Interval to get counters. If None, all counters will be returned
|
||||
interval: Interval in seconds to get counters. If None, all counters will be returned
|
||||
max_intervals: Maximum number of intervals to get. If None, all intervals will be returned
|
||||
limit: Maximum number of counters to get. If None, all counters will be returned
|
||||
use_max: If True, the maximum value of the counter will be returned instead of the sum
|
||||
|
@ -173,7 +173,7 @@ def enumerate_counters(
|
||||
counter_type: Type of counter to get
|
||||
since: From when to get counters
|
||||
to: To when to get counters
|
||||
interval: Interval to get counters
|
||||
interval: Interval in seconds to get counters
|
||||
max_intervals: Max intervals to get
|
||||
limit: Max number of results to get
|
||||
use_max: If limit is reached, use max_intervals to get more results
|
||||
|
@ -163,7 +163,6 @@ class ReportAuto(Report, metaclass=ReportAutoType):
|
||||
intervals.append((start, next))
|
||||
start = next
|
||||
|
||||
logger.debug('Intervals: %s', intervals)
|
||||
return intervals
|
||||
|
||||
def adjust_date(self, d: datetime.date, is_ending_date: bool) -> datetime.date:
|
||||
|
@ -29,7 +29,9 @@
|
||||
"""
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import logging
|
||||
import time
|
||||
import typing
|
||||
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
@ -62,58 +64,61 @@ class AuthenticatorsStats(StatsReportAuto):
|
||||
uuid = 'a5a43bc0-d543-11ea-af8f-af01fa65994e'
|
||||
|
||||
def generate(self) -> bytes:
|
||||
|
||||
stats: list[dict[str, typing.Any]] = []
|
||||
|
||||
exec_start = time.time()
|
||||
|
||||
interval = self.get_interval_as_hours() * 3600 # Convert to seconds
|
||||
|
||||
start = datetime.datetime.combine(self.starting_date(), datetime.time.min)
|
||||
to = datetime.datetime.combine(self.ending_date(), datetime.time.max)
|
||||
|
||||
for a in self.get_model_records():
|
||||
# Will show a.name on every change...
|
||||
stats.append({'date': a.name, 'users': None})
|
||||
|
||||
for i in self.get_intervals_list():
|
||||
start = i[0]
|
||||
end = i[1]
|
||||
data = [0, 0, 0]
|
||||
# Get stats for interval
|
||||
for counter in counters.enumerate_counters(
|
||||
typing.cast('models.Authenticator', a),
|
||||
auth = typing.cast('models.Authenticator', a)
|
||||
|
||||
for counter1, counter2, counter3 in zip(
|
||||
counters.enumerate_counters(
|
||||
auth,
|
||||
counters.types.stats.CounterType.AUTH_SERVICES,
|
||||
since=start,
|
||||
to=end,
|
||||
interval=BIG_INTERVAL,
|
||||
to=to,
|
||||
interval=interval,
|
||||
limit=MAX_ELEMENTS,
|
||||
use_max=True,
|
||||
):
|
||||
data[0] += counter[1]
|
||||
|
||||
for counter in counters.enumerate_counters(
|
||||
typing.cast('models.Authenticator', a),
|
||||
),
|
||||
counters.enumerate_counters(
|
||||
auth,
|
||||
counters.types.stats.CounterType.AUTH_USERS_WITH_SERVICES,
|
||||
since=start,
|
||||
to=end,
|
||||
interval=BIG_INTERVAL,
|
||||
to=to,
|
||||
interval=interval,
|
||||
limit=MAX_ELEMENTS,
|
||||
use_max=True,
|
||||
):
|
||||
data[1] += counter[1]
|
||||
for counter in counters.enumerate_counters(
|
||||
typing.cast('models.Authenticator', a),
|
||||
),
|
||||
counters.enumerate_counters(
|
||||
auth,
|
||||
counters.types.stats.CounterType.AUTH_USERS,
|
||||
since=start,
|
||||
to=end,
|
||||
interval=BIG_INTERVAL,
|
||||
to=to,
|
||||
interval=interval,
|
||||
limit=MAX_ELEMENTS,
|
||||
use_max=True,
|
||||
):
|
||||
data[2] += counter[1]
|
||||
|
||||
),
|
||||
):
|
||||
stats.append(
|
||||
{
|
||||
'date': self.format_datetime_as_string(start),
|
||||
'users': data[0],
|
||||
'services': data[1],
|
||||
'user_services': data[2],
|
||||
'date': self.format_datetime_as_string(counter1[0]),
|
||||
'users': counter3[1],
|
||||
'services': counter1[1],
|
||||
'user_services': counter2[1],
|
||||
}
|
||||
)
|
||||
logger.debug('Report Data Done')
|
||||
|
||||
logger.debug('Report Data Done. Elapsed time: %s', time.time() - exec_start)
|
||||
|
||||
return self.template_as_pdf(
|
||||
'uds/reports/stats/authenticator_stats.html',
|
||||
dct={'data': stats},
|
||||
|
File diff suppressed because one or more lines are too long
@ -102,6 +102,6 @@
|
||||
</svg>
|
||||
</div>
|
||||
</uds-root>
|
||||
<link rel="modulepreload" href="/uds/res/admin/chunk-2F3F2YC2.js?stamp=1734969583" integrity="sha384-VVOra5xy5Xg9fYkBmK9MLhX7vif/MexRAaLIDBsQ4ZlkF31s/U6uWWrj+LAnvX/q"><script src="/uds/res/admin/polyfills.js?stamp=1734969583" type="module" crossorigin="anonymous" integrity="sha384-TVRkn44wOGJBeCKWJBHWLvXubZ+Julj/yA0OoEFa3LgJHVHaPeeATX6NcjuNgsIA"></script><script src="/uds/res/admin/main.js?stamp=1734969583" type="module" crossorigin="anonymous" integrity="sha384-sMRYBCL3FR0Leq8toSr9C2/cSxvENp5xFXa2rLXgi5HjO4Pc/aQ3GcA6QgWln3JX"></script></body>
|
||||
<link rel="modulepreload" href="/uds/res/admin/chunk-2F3F2YC2.js?stamp=1737566375" integrity="sha384-VVOra5xy5Xg9fYkBmK9MLhX7vif/MexRAaLIDBsQ4ZlkF31s/U6uWWrj+LAnvX/q"><script src="/uds/res/admin/polyfills.js?stamp=1737566375" type="module" crossorigin="anonymous" integrity="sha384-TVRkn44wOGJBeCKWJBHWLvXubZ+Julj/yA0OoEFa3LgJHVHaPeeATX6NcjuNgsIA"></script><script src="/uds/res/admin/main.js?stamp=1737566375" type="module" crossorigin="anonymous" integrity="sha384-X1/ISiXOGMpaqthPYQSfK0iCO/Ha6rJ6kVSmMD9dI/vP31We3YdD70NxbOX5A63w"></script></body>
|
||||
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user