misc: remove redis specific code (#82579)
gitea/authentic2-cut/pipeline/head This commit looks good
Details
gitea/authentic2-cut/pipeline/head This commit looks good
Details
It was used to aggregate statistics, those statistics are now part of authentic2 standard features.
This commit is contained in:
parent
2e30eb42ed
commit
5ec29713db
|
@ -13,7 +13,6 @@ Package: python3-authentic2-cut
|
|||
Architecture: all
|
||||
Depends: graphicsmagick-imagemagick-compat,
|
||||
python3-authentic2,
|
||||
python3-django-redis,
|
||||
python3-magic,
|
||||
python3-pil,
|
||||
python3-sorl-thumbnail,
|
||||
|
|
|
@ -593,18 +593,8 @@ class AppConfig(django.apps.AppConfig):
|
|||
if partner:
|
||||
user.attributes.validation_partner = partner
|
||||
|
||||
@property
|
||||
def redis_client(self):
|
||||
from django.core import cache
|
||||
|
||||
return cache.cache.client.get_client()
|
||||
|
||||
def stat(self, *args):
|
||||
t = now()
|
||||
key = 'stat__%s%02d__' % (t.date(), t.hour)
|
||||
key += '__'.join(args)
|
||||
self.redis_client.expire(key, 3600 * 24 * 7)
|
||||
self.redis_client.incr(key)
|
||||
pass
|
||||
|
||||
def cut_event_login(self, user, how, service=None, **kwargs):
|
||||
# log login for current user
|
||||
|
@ -617,7 +607,6 @@ class AppConfig(django.apps.AppConfig):
|
|||
if service:
|
||||
msg += ' pour %s' % service
|
||||
self.log_action(user, msg)
|
||||
self.stat('login', method)
|
||||
|
||||
def cut_event_registration(self, user, view, form, token, service, **kwargs):
|
||||
# log registration for current user
|
||||
|
@ -632,7 +621,6 @@ class AppConfig(django.apps.AppConfig):
|
|||
user.attributes.creation_partner = service
|
||||
|
||||
def cut_event_sso_request(self, idp, service, **kwargs):
|
||||
self.stat('sso-request', service.slug)
|
||||
from authentic2.middleware import StoreRequestMiddleware
|
||||
|
||||
request = StoreRequestMiddleware.get_request()
|
||||
|
@ -644,7 +632,6 @@ class AppConfig(django.apps.AppConfig):
|
|||
self.log_action(user, msg)
|
||||
how = self.get_authentication_how()
|
||||
method = self.get_authentication_method(how)
|
||||
self.stat('sso-success', service.slug, method or 'inconnu')
|
||||
|
||||
def cut_event_cut_edit_core(self, user, form, **kwargs):
|
||||
if not form.has_changed():
|
||||
|
|
|
@ -128,30 +128,6 @@ def pdf_file():
|
|||
yield fd.read()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def redis_client(monkeypatch):
|
||||
from authentic2_cut.apps import AppConfig
|
||||
|
||||
class RedisClientMock:
|
||||
def __init__(self):
|
||||
self.contents = {}
|
||||
self.timeouts = {}
|
||||
|
||||
def expire(self, key, delta):
|
||||
if delta:
|
||||
self.timeouts[key] = time.time() + delta
|
||||
elif key in self.expire:
|
||||
del self.timeouts[key]
|
||||
|
||||
def incr(self, key):
|
||||
self.contents.setdefault(key, 0)
|
||||
self.contents[key] += 1
|
||||
|
||||
redis_client = RedisClientMock()
|
||||
monkeypatch.setattr(AppConfig, 'redis_client', redis_client)
|
||||
yield redis_client
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_caches():
|
||||
from authentic2.apps.journal.models import event_type_cache
|
||||
|
|
Loading…
Reference in New Issue