mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 11:51:05 -05:00
remove redis debug config var
This commit is contained in:
@@ -11,8 +11,6 @@ if os.environ.get('VCAP_APPLICATION'):
|
||||
|
||||
|
||||
class Config(object):
|
||||
NOTIFY_ADMIN_API_CACHE_ENABLED = False # TODO: remove when redis is fixed on remote
|
||||
|
||||
ADMIN_CLIENT_SECRET = os.environ.get('ADMIN_CLIENT_SECRET')
|
||||
ADMIN_CLIENT_USER_NAME = os.environ.get('ADMIN_CLIENT_USERNAME')
|
||||
API_HOST_NAME = os.environ.get('API_HOST_NAME', 'localhost')
|
||||
@@ -130,7 +128,6 @@ class Development(Config):
|
||||
|
||||
|
||||
class Test(Development):
|
||||
NOTIFY_ADMIN_API_CACHE_ENABLED = True
|
||||
BASIC_AUTH_FORCE = False
|
||||
DEBUG = True
|
||||
TESTING = True
|
||||
|
||||
@@ -3,15 +3,7 @@ import re
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
|
||||
from flask import (
|
||||
abort,
|
||||
current_app,
|
||||
flash,
|
||||
redirect,
|
||||
render_template,
|
||||
request,
|
||||
url_for,
|
||||
)
|
||||
from flask import abort, flash, redirect, render_template, request, url_for
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app import (
|
||||
@@ -468,13 +460,12 @@ def platform_admin_returned_letters():
|
||||
|
||||
try:
|
||||
letter_jobs_client.submit_returned_letters(references)
|
||||
if current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
redis_client.delete_by_pattern(
|
||||
'service-????????-????-????-????-????????????-returned-letters-statistics'
|
||||
)
|
||||
redis_client.delete_by_pattern(
|
||||
'service-????????-????-????-????-????????????-returned-letters-summary'
|
||||
)
|
||||
redis_client.delete_by_pattern(
|
||||
'service-????????-????-????-????-????????????-returned-letters-statistics'
|
||||
)
|
||||
redis_client.delete_by_pattern(
|
||||
'service-????????-????-????-????-????????????-returned-letters-summary'
|
||||
)
|
||||
except HTTPError as error:
|
||||
if error.status_code == 400:
|
||||
error_references = [
|
||||
@@ -547,13 +538,10 @@ def clear_cache():
|
||||
groups = map(CACHE_KEYS.get, group_keys)
|
||||
patterns = list(itertools.chain(*groups))
|
||||
|
||||
if current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
num_deleted = sum(
|
||||
redis_client.delete_by_pattern(pattern)
|
||||
for pattern in patterns
|
||||
)
|
||||
else:
|
||||
num_deleted = 0
|
||||
num_deleted = sum(
|
||||
redis_client.delete_by_pattern(pattern)
|
||||
for pattern in patterns
|
||||
)
|
||||
|
||||
msg = (
|
||||
f'Removed {num_deleted} objects '
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from flask import current_app
|
||||
|
||||
from app.extensions import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
|
||||
@@ -102,12 +100,11 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
data = _attach_current_user(data)
|
||||
job = self.post(url='/service/{}/job'.format(service_id), data=data)
|
||||
|
||||
if current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
redis_client.set(
|
||||
'has_jobs-{}'.format(service_id),
|
||||
b'true',
|
||||
ex=int(cache.DEFAULT_TTL),
|
||||
)
|
||||
redis_client.set(
|
||||
'has_jobs-{}'.format(service_id),
|
||||
b'true',
|
||||
ex=int(cache.DEFAULT_TTL),
|
||||
)
|
||||
|
||||
return job
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from itertools import chain
|
||||
|
||||
from flask import current_app
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.extensions import redis_client
|
||||
@@ -54,12 +53,11 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
def update_organisation(self, org_id, cached_service_ids=None, **kwargs):
|
||||
api_response = self.post(url="/organisations/{}".format(org_id), data=kwargs)
|
||||
|
||||
if current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
if cached_service_ids:
|
||||
redis_client.delete(*map('service-{}'.format, cached_service_ids))
|
||||
if cached_service_ids:
|
||||
redis_client.delete(*map('service-{}'.format, cached_service_ids))
|
||||
|
||||
if 'name' in kwargs:
|
||||
redis_client.delete(f'organisation-{org_id}-name')
|
||||
if 'name' in kwargs:
|
||||
redis_client.delete(f'organisation-{org_id}-name')
|
||||
|
||||
return api_response
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
from flask import current_app
|
||||
from notifications_utils.clients.redis import daily_limit_cache_key
|
||||
|
||||
from app.extensions import redis_client
|
||||
@@ -139,7 +138,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
# @cache.delete('service-{service_id}-templates')
|
||||
# @cache.delete_by_pattern('service-{service_id}-template-*')
|
||||
def archive_service(self, service_id, cached_service_user_ids):
|
||||
if cached_service_user_ids and current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
if cached_service_user_ids:
|
||||
redis_client.delete(*map('user-{}'.format, cached_service_user_ids))
|
||||
return self.post('/service/{}/archive'.format(service_id), data=None)
|
||||
|
||||
@@ -596,7 +595,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
broadcast channel is one of "operator", "test", "severe", "government"
|
||||
provider_restriction is one of "all", "three", "o2", "vodafone", "ee"
|
||||
"""
|
||||
if cached_service_user_ids and current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
if cached_service_user_ids:
|
||||
redis_client.delete(*map('user-{}'.format, cached_service_user_ids))
|
||||
|
||||
data = {
|
||||
@@ -610,10 +609,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
def get_notification_count(self, service_id):
|
||||
# if cache is not set, or not enabled, return 0
|
||||
|
||||
if current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
count = redis_client.get(daily_limit_cache_key(service_id)) or 0
|
||||
else:
|
||||
count = 0
|
||||
count = redis_client.get(daily_limit_cache_key(service_id)) or 0
|
||||
|
||||
return int(count)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from flask import current_app
|
||||
|
||||
from app.extensions import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
@@ -50,7 +48,7 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
|
||||
'folders': list(folder_ids),
|
||||
})
|
||||
|
||||
if template_ids and current_app.config['NOTIFY_ADMIN_API_CACHE_ENABLED']:
|
||||
if template_ids:
|
||||
redis_client.delete(*(f'service-{service_id}-template-{id}-version-None' for id in template_ids))
|
||||
|
||||
# @cache.delete('service-{service_id}-template-folders')
|
||||
|
||||
Reference in New Issue
Block a user