mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Merge branch 'master' into refactor-send-tasks-into-shared-code
Conflicts: app/celery/provider_tasks.py tests/app/celery/test_provider_tasks.py
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
from sqlalchemy import func, cast, Float, case
|
||||
from sqlalchemy import func
|
||||
|
||||
from app import db
|
||||
from app.models import (
|
||||
ProviderStatistics,
|
||||
ProviderDetails,
|
||||
NotificationHistory,
|
||||
SMS_TYPE,
|
||||
EMAIL_TYPE,
|
||||
@@ -12,15 +10,6 @@ from app.models import (
|
||||
)
|
||||
|
||||
|
||||
def get_provider_statistics(service, **kwargs):
|
||||
query = ProviderStatistics.query.filter_by(service=service)
|
||||
if 'providers' in kwargs:
|
||||
providers = ProviderDetails.query.filter(ProviderDetails.identifier.in_(kwargs['providers'])).all()
|
||||
provider_ids = [provider.id for provider in providers]
|
||||
query = query.filter(ProviderStatistics.provider_id.in_(provider_ids))
|
||||
return query
|
||||
|
||||
|
||||
def get_fragment_count(service_id):
|
||||
shared_filters = [
|
||||
NotificationHistory.service_id == service_id,
|
||||
|
||||
@@ -79,6 +79,7 @@ def send_email_to_provider(notification):
|
||||
send_email_response.apply_async(
|
||||
(provider.get_name(), reference, notification.to), queue='research-mode'
|
||||
)
|
||||
notification.billable_units = 0
|
||||
else:
|
||||
from_address = '"{}" <{}@{}>'.format(service.name, service.email_from,
|
||||
current_app.config['NOTIFY_EMAIL_DOMAIN'])
|
||||
|
||||
@@ -213,6 +213,7 @@ def get_all_notifications_for_service(service_id):
|
||||
page = data['page'] if 'page' in data else 1
|
||||
page_size = data['page_size'] if 'page_size' in data else current_app.config.get('PAGE_SIZE')
|
||||
limit_days = data.get('limit_days')
|
||||
include_jobs = data.get('include_jobs', True)
|
||||
|
||||
pagination = notifications_dao.get_notifications_for_service(
|
||||
service_id,
|
||||
@@ -220,7 +221,7 @@ def get_all_notifications_for_service(service_id):
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
limit_days=limit_days,
|
||||
include_jobs=True)
|
||||
include_jobs=include_jobs)
|
||||
kwargs = request.args.to_dict()
|
||||
kwargs['service_id'] = service_id
|
||||
return jsonify(
|
||||
|
||||
Reference in New Issue
Block a user