Merge branch 'master' of https://github.com/alphagov/notifications-api into add-reply-to-notifications

This commit is contained in:
venusbb
2017-11-27 13:53:37 +00:00
6 changed files with 2 additions and 184 deletions

View File

@@ -297,40 +297,6 @@ def _stats_for_service_query(service_id):
)
@statsd(namespace="dao")
def dao_fetch_monthly_historical_stats_by_template_for_service(service_id, year):
month = get_london_month_from_utc_column(NotificationHistory.created_at)
start_date, end_date = get_financial_year(year)
sq = db.session.query(
NotificationHistory.template_id,
NotificationHistory.status,
month.label('month'),
func.count().label('count')
).filter(
NotificationHistory.service_id == service_id,
NotificationHistory.created_at.between(start_date, end_date)
).group_by(
month,
NotificationHistory.template_id,
NotificationHistory.status
).subquery()
rows = db.session.query(
Template.id.label('template_id'),
Template.name,
Template.template_type,
sq.c.status,
sq.c.count.label('count'),
sq.c.month
).join(
sq,
sq.c.template_id == Template.id
).all()
return format_monthly_template_notification_stats(year, rows)
@statsd(namespace="dao")
def dao_fetch_monthly_historical_stats_for_service(service_id, year):
month = get_london_month_from_utc_column(NotificationHistory.created_at)

View File

@@ -60,10 +60,10 @@ def receive_firetext_sms():
auth = request.authorization
if not auth:
current_app.logger.warning("Inbound sms no auth header")
# abort(401)
abort(401)
elif auth.username != 'notify' or auth.password not in current_app.config['FIRETEXT_INBOUND_SMS_AUTH']:
current_app.logger.warning("Inbound sms incorrect username ({}) or password".format(auth.username))
# abort(403)
abort(403)
inbound_number = strip_leading_forty_four(post_data['destination'])

View File

@@ -37,7 +37,6 @@ from app.dao.services_dao import (
dao_fetch_all_services,
dao_fetch_all_services_by_user,
dao_fetch_monthly_historical_stats_for_service,
dao_fetch_monthly_historical_stats_by_template_for_service,
dao_fetch_monthly_historical_usage_by_template_for_service,
dao_fetch_service_by_id,
dao_fetch_stats_for_service,
@@ -541,18 +540,6 @@ def get_monthly_template_usage(service_id):
raise InvalidRequest('Year must be a number', status_code=400)
@service_blueprint.route('/<uuid:service_id>/notifications/templates/monthly', methods=['GET'])
def get_monthly_template_stats(service_id):
service = dao_fetch_service_by_id(service_id)
try:
return jsonify(data=dao_fetch_monthly_historical_stats_by_template_for_service(
service.id,
int(request.args.get('year', 'NaN'))
))
except ValueError:
raise InvalidRequest('Year must be a number', status_code=400)
@service_blueprint.route('/<uuid:service_id>/inbound-api', methods=['POST'])
def create_service_inbound_api(service_id):
data = request.get_json()