mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-23 09:29:43 -04:00
fix some issues uncovered during testing
This commit is contained in:
@@ -42,6 +42,7 @@ from app.v2.errors import TooManyRequestsError
|
||||
|
||||
@notify_celery.task(name="process-job")
|
||||
def process_job(job_id, sender_id=None):
|
||||
current_app.logger.warning("ENTER process_job")
|
||||
start = datetime.utcnow()
|
||||
job = dao_get_job_by_id(job_id)
|
||||
current_app.logger.info("Starting process-job task for job id {} with status: {}".format(job_id, job.job_status))
|
||||
@@ -166,10 +167,10 @@ def __total_sending_limits_for_job_exceeded(service, job, job_id):
|
||||
else:
|
||||
return False
|
||||
except TooManyRequestsError:
|
||||
job.job_status = 'total sending limits exceeded'
|
||||
job.job_status = 'sending limits exceeded'
|
||||
job.processing_finished = datetime.utcnow()
|
||||
dao_update_job(job)
|
||||
current_app.logger.info(
|
||||
current_app.logger.error(
|
||||
"Job {} size {} error. Total sending limits {} exceeded".format(
|
||||
job_id, job.notification_count, service.message_limit)
|
||||
)
|
||||
|
||||
@@ -436,7 +436,7 @@ class Service(db.Model, Versioned):
|
||||
active = db.Column(db.Boolean, index=False, unique=False, nullable=False, default=True)
|
||||
message_limit = db.Column(db.BigInteger, index=False, unique=False, nullable=False)
|
||||
# TODO nullable if we are adding it late?
|
||||
total_message_limit = db.Column(db.BigInteger, index=False, unique=False, nullable=False, default=250000)
|
||||
total_message_limit = db.Column(db.BigInteger, index=False, unique=False, nullable=False, default=7)
|
||||
restricted = db.Column(db.Boolean, index=False, unique=False, nullable=False)
|
||||
research_mode = db.Column(db.Boolean, index=False, unique=False, nullable=False, default=False)
|
||||
email_from = db.Column(db.Text, index=False, unique=True, nullable=False)
|
||||
|
||||
@@ -142,7 +142,7 @@ def persist_notification(
|
||||
if key_type != KEY_TYPE_TEST and current_app.config['REDIS_ENABLED']:
|
||||
current_app.logger.info('Redis enabled, querying cache key for service id: {}'.format(service.id))
|
||||
cache_key = redis.daily_limit_cache_key(service.id)
|
||||
total_key = redis.daily_total_cache_key()
|
||||
total_key = redis.total_limit_cache_key(service.id)
|
||||
current_app.logger.info('Redis daily limit cache key: {}'.format(cache_key))
|
||||
if redis_store.get(cache_key) is None:
|
||||
current_app.logger.info('Redis daily limit cache key does not exist')
|
||||
@@ -163,7 +163,8 @@ def persist_notification(
|
||||
else:
|
||||
current_app.logger.info('Redis total limit cache key does exist')
|
||||
redis_store.incr(total_key)
|
||||
current_app.logger.info('Redis total limit cache key has been incremented')
|
||||
current_app.logger.info(
|
||||
f'Redis total limit cache key has been incremented to {redis_store.get(total_key)}')
|
||||
current_app.logger.info(
|
||||
"{} {} created at {}".format(notification_type, notification_id, notification_created_at)
|
||||
)
|
||||
|
||||
@@ -87,7 +87,7 @@ def check_service_over_total_message_limit(key_type, service):
|
||||
redis_store.set(cache_key, service_stats, ex=86400)
|
||||
return service_stats
|
||||
if int(service_stats) >= service.total_message_limit:
|
||||
current_app.logger.info(
|
||||
current_app.logger.warning(
|
||||
"service {} has been rate limited for total use sent {} limit {}".format(
|
||||
service.id, int(service_stats), service.total_message_limit)
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from flask import current_app
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from app.config import QueueNames
|
||||
|
||||
Reference in New Issue
Block a user