diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 46db6b1c9..807b17147 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -263,7 +263,7 @@ def service_switch_count_as_live(service_id): ) if form.validate_on_submit(): - current_service.update(count_as_live=form.enabled.data) + current_service.update_count_as_live(form.enabled.data) return redirect(url_for('.service_settings', service_id=service_id)) return render_template( diff --git a/app/models/service.py b/app/models/service.py index 3a45f6a17..7b09ca5e5 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -65,6 +65,9 @@ class Service(JSONModel): def update(self, **kwargs): return service_api_client.update_service(self.id, **kwargs) + def update_count_as_live(self, count_as_live): + return service_api_client.update_count_as_live(self.id, count_as_live=count_as_live) + def update_status(self, live): return service_api_client.update_status(self.id, live=live) diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index aa6086c6a..8adbee048 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -114,6 +114,13 @@ class ServiceAPIClient(NotifyAdminAPIClient): go_live_at=str(datetime.utcnow()) if live else None ) + @cache.delete('live-service-and-organisation-counts') + def update_count_as_live(self, service_id, count_as_live): + return self.update_service( + service_id, + count_as_live=count_as_live, + ) + # This method is not cached because it calls through to one which is def update_service_with_properties(self, service_id, properties): return self.update_service(service_id, **properties)