Automate counting of live services and orgs

Returns the data calculated by the API. Stored in Redis against a
hardcoded key so that no-one hammering the home page is directly hitting
the database.
This commit is contained in:
Chris Hill-Scott
2019-04-10 17:20:51 +01:00
parent 55eaa066f1
commit 9863aa3c48
10 changed files with 61 additions and 15 deletions

View File

@@ -12,7 +12,7 @@ from notifications_utils.international_billing_rates import (
)
from notifications_utils.template import HTMLEmailTemplate, LetterImageTemplate
from app import email_branding_client, letter_branding_client
from app import email_branding_client, letter_branding_client, status_api_client
from app.main import main
from app.main.forms import FieldWithNoneOption, SearchByNameForm
from app.main.views.sub_navigation_dictionaries import features_nav
@@ -21,9 +21,14 @@ from app.utils import AgreementInfo, get_logo_cdn_domain
@main.route('/')
def index():
if current_user and current_user.is_authenticated:
return redirect(url_for('main.choose_account'))
return render_template('views/signedout.html')
return render_template(
'views/signedout.html',
counts=status_api_client.get_count_of_live_services_and_organisations(),
)
@main.route('/robots.txt')

View File

@@ -262,12 +262,7 @@ def service_switch_live(service_id):
)
if form.validate_on_submit():
current_service.update(
# TODO This limit should be set depending on the agreement signed by
# with Notify.
message_limit=250000 if form.enabled.data else 50,
restricted=(not form.enabled.data)
)
current_service.update_status(live=form.enabled.data)
return redirect(url_for('.service_settings', service_id=service_id))
return render_template(