diff --git a/met-api/src/met_api/services/engagement_service.py b/met-api/src/met_api/services/engagement_service.py index 9e8a69145..9a366f918 100644 --- a/met-api/src/met_api/services/engagement_service.py +++ b/met-api/src/met_api/services/engagement_service.py @@ -10,6 +10,7 @@ from met_api.exceptions.business_exception import BusinessException from met_api.models.engagement import Engagement as EngagementModel from met_api.models.engagement_scope_options import EngagementScopeOptions +from met_api.models.engagement_settings import EngagementSettingsModel from met_api.models.engagement_slug import EngagementSlug as EngagementSlugModel from met_api.models.engagement_status_block import EngagementStatusBlock as EngagementStatusBlockModel from met_api.models.pagination_options import PaginationOptions @@ -131,8 +132,12 @@ def _get_scope_options(user_roles, has_team_access): def close_engagements_due(): """Close published engagements that are due for a closeout.""" engagements = EngagementModel.close_engagements_due() - results = [EngagementService._send_closeout_emails(engagement) for engagement in engagements] - return results + for engagement in engagements: + engagement_settings: EngagementSettingsModel =\ + EngagementSettingsModel.find_by_id(engagement.id) + if engagement_settings: + if engagement_settings.send_report: + EngagementService._send_closeout_emails(engagement) @staticmethod def publish_scheduled_engagements():