add tada to makefile

This commit is contained in:
Kenneth Kehl
2025-01-23 13:41:13 -08:00
parent 0d874828e4
commit 49f4129e5b
5 changed files with 24 additions and 21 deletions

View File

@@ -49,9 +49,7 @@ jobs:
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
- name: Check imports alphabetized - name: Check imports alphabetized
run: poetry run isort ./app ./tests run: poetry run isort --check-only ./app ./tests
- name: Run formatting
run: poetry run black .
- name: Run style checks - name: Run style checks
run: poetry run flake8 . run: poetry run flake8 .
- name: Check for dead code - name: Check for dead code

View File

@@ -31,6 +31,14 @@ bootstrap-with-docker: ## Build the image to run the app in Docker
run-procfile: run-procfile:
poetry run honcho start -f Procfile.dev poetry run honcho start -f Procfile.dev
.PHONY: tada
tada:
poetry run isort .
poetry run black .
poetry run flake8 .
.PHONY: avg-complexity .PHONY: avg-complexity
avg-complexity: avg-complexity:
echo "*** Shows average complexity in radon of all code ***" echo "*** Shows average complexity in radon of all code ***"

View File

@@ -119,10 +119,8 @@ def send_sms_to_provider(notification):
} }
db.session.close() # no commit needed as no changes to objects have been made above db.session.close() # no commit needed as no changes to objects have been made above
message_id = provider.send_sms(**send_sms_kwargs) message_id = provider.send_sms(**send_sms_kwargs)
update_notification_message_id(notification.id, message_id) update_notification_message_id(notification.id, message_id)
except Exception as e: except Exception as e:
n = notification n = notification

View File

@@ -6,17 +6,14 @@ from app.dao.notifications_dao import dao_get_notification_count_for_service
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
from app.enums import KeyType, NotificationType, ServicePermissionType, TemplateType from app.enums import KeyType, NotificationType, ServicePermissionType, TemplateType
from app.errors import BadRequestError, RateLimitError, TotalRequestsError from app.errors import BadRequestError, TotalRequestsError
from app.models import ServicePermission from app.models import ServicePermission
from app.notifications.process_notifications import create_content_for_notification from app.notifications.process_notifications import create_content_for_notification
from app.serialised_models import SerialisedTemplate from app.serialised_models import SerialisedTemplate
from app.service.utils import service_allowed_to_send_to from app.service.utils import service_allowed_to_send_to
from app.utils import get_public_notify_type_text, hilite from app.utils import get_public_notify_type_text, hilite
from notifications_utils import SMS_CHAR_COUNT_LIMIT from notifications_utils import SMS_CHAR_COUNT_LIMIT
from notifications_utils.clients.redis import ( from notifications_utils.clients.redis import total_limit_cache_key
rate_limit_cache_key,
total_limit_cache_key,
)
from notifications_utils.recipients import ( from notifications_utils.recipients import (
get_international_phone_info, get_international_phone_info,
validate_and_format_email_address, validate_and_format_email_address,
@@ -45,10 +42,10 @@ def check_service_over_total_message_limit(key_type, service):
# add service api to return total_message_limit and actual number of messages for service # add service api to return total_message_limit and actual number of messages for service
if service_stats is None: if service_stats is None:
service_stats = 0 service_stats = 0
redis_store.set(cache_key, service_stats, ex=365*24*60*60) redis_store.set(cache_key, service_stats, ex=365 * 24 * 60 * 60)
return service_stats return service_stats
if int(service_stats) >= 5: if int(service_stats) >= 5:
#if int(service_stats) >= service.total_message_limit: # if int(service_stats) >= service.total_message_limit:
current_app.logger.warning( current_app.logger.warning(
"service {} has been rate limited for total use sent {} limit {}".format( "service {} has been rate limited for total use sent {} limit {}".format(
service.id, int(service_stats), service.total_message_limit service.id, int(service_stats), service.total_message_limit
@@ -56,7 +53,11 @@ def check_service_over_total_message_limit(key_type, service):
) )
raise TotalRequestsError(service.total_message_limit) raise TotalRequestsError(service.total_message_limit)
else: else:
print(hilite(f"TOTAL MESSAGE LIMIT {service.total_message_limit} CURRENT {service_stats}")) print(
hilite(
f"TOTAL MESSAGE LIMIT {service.total_message_limit} CURRENT {service_stats}"
)
)
return int(service_stats) return int(service_stats)
@@ -77,11 +78,6 @@ def check_application_over_retention_limit(key_type, service):
return int(total_stats) return int(total_stats)
def check_rate_limiting(service, api_key):
check_service_over_api_rate_limit(service, api_key)
check_application_over_retention_limit(api_key.key_type, service)
def check_template_is_for_notification_type(notification_type, template_type): def check_template_is_for_notification_type(notification_type, template_type):
if notification_type != template_type: if notification_type != template_type:
message = "{0} template is not suitable for {1} notification".format( message = "{0} template is not suitable for {1} notification".format(

View File

@@ -15,9 +15,12 @@ revision = "0414_change_total_message_limit"
def upgrade(): def upgrade():
# TODO This needs updating when the agreement model is ready. We only want free tier at 100k # TODO This needs updating when the agreement model is ready. We only want free tier at 100k
op.execute("UPDATE services set total_message_limit=100000 where total_message_limit=250000") op.execute(
"UPDATE services set total_message_limit=100000 where total_message_limit=250000"
)
def downgrade(): def downgrade():
op.execute("UPDATE services set total_message_limit=250000 where total_message_limit=100000") op.execute(
"UPDATE services set total_message_limit=250000 where total_message_limit=100000"
)