Merge pull request #1939 from alphagov/delete-old-platform-admin-code

Delete old platform-stats route
This commit is contained in:
Katie Smith
2018-07-11 14:22:27 +01:00
committed by GitHub
3 changed files with 0 additions and 96 deletions

View File

@@ -380,35 +380,6 @@ def fetch_stats_by_date_range_for_all_services(start_date, end_date, include_fro
return query.all()
@statsd(namespace='dao')
def fetch_aggregate_stats_by_date_range_for_all_services(start_date, end_date, include_from_test_key=True):
start_date = get_london_midnight_in_utc(start_date)
end_date = get_london_midnight_in_utc(end_date + timedelta(days=1))
table = NotificationHistory
if start_date >= datetime.utcnow() - timedelta(days=7):
table = Notification
query = db.session.query(
table.notification_type,
table.status,
func.count(table.id).label('count')
).filter(
table.created_at >= start_date,
table.created_at < end_date
).group_by(
table.notification_type,
table.status
).order_by(
table.notification_type
)
if not include_from_test_key:
query = query.filter(table.key_type != KEY_TYPE_TEST)
return query.all()
@transactional
@version_class(Service)
@version_class(ApiKey)

View File

@@ -47,7 +47,6 @@ from app.dao.services_dao import (
dao_remove_user_from_service,
dao_suspend_service,
dao_update_service,
fetch_aggregate_stats_by_date_range_for_all_services,
fetch_stats_by_date_range_for_all_services
)
from app.dao.service_whitelist_dao import (
@@ -116,25 +115,6 @@ def handle_integrity_error(exc):
return jsonify(result='error', message="Internal server error"), 500
@service_blueprint.route('/platform-stats', methods=['GET'])
def get_platform_stats():
include_from_test_key = request.args.get('include_from_test_key', 'True') != 'False'
# If start and end date are not set, we are expecting today's stats.
today = str(datetime.utcnow().date())
start_date = datetime.strptime(request.args.get('start_date', today), '%Y-%m-%d').date()
end_date = datetime.strptime(request.args.get('end_date', today), '%Y-%m-%d').date()
data = fetch_aggregate_stats_by_date_range_for_all_services(start_date=start_date,
end_date=end_date,
include_from_test_key=include_from_test_key
)
stats = statistics.format_statistics(data)
result = jsonify(stats)
return result
@service_blueprint.route('', methods=['GET'])
def get_services():
only_active = request.args.get('only_active') == 'True'