Uploaded image for project: 'CFA MX '
  1. CFA MX
  2. CFAMX-12750

Query Mailer - Update to put query results in the body of the email

    Details

    • Source Code ID(s):
    • Sprint:
      CFAMX Angular Update Sprint 1

      Description

      As a Product Owner I want the Query Mailer to be enhanced so that the results of a query can be output directly into the body of the email

      Notes

      • When chatting with Colin Wyatt-Goodall, we discussed setting a limit of sorts to automagically toggle between putting the content into the body of the email and attaching it. I will leave the decision of breakpoint to development
      • On of the things driving this requirement is that the current process requires that the attachment has to be opened everyday, and it will be easier to have some data in the body of the email and apply rules to that content (either in an email app, or some other tool)

      Acceptance Criteria

      1. Confirm that the results of a query will be displayed in the body of the email if the setting is enabled
      2. Confirm that the limit is documented
      3. Confirm that the results of a query will be included in an attachment if set to do so
      4. Confirm the query mailer automagically sends the results to the body of the email, or as an attachment

      Sample Query

      DECLARE
      	@dayofweek VARCHAR(100) = datename(dw,getdate())
      ;
      SELECT (CONVERT(DATE, GETDATE()))[Import Date],@dayofweek [Import Day], db_name() [Environment]
      ;
      BEGIN
      IF @dayofweek = 'Saturday'
      	BEGIN
      		SELECT '----------------------------------------------' AS 'Today is Saturday - no Full Forecasts for Sundays'
      	END
      ELSE
      	BEGIN
      		Select COUNT(1) AS FullForecastsNotImported
      		from tbentityzone ez with(nolock)
      		join tbentity e with(nolock) on ez.entityid = e.entityid
      		where ez.ZoneID = 770
      		AND e.Status != 'Closed'
      		and e.TempCloseDate is Null
      		AND ez.EntityID not in (
      			select EntityID from Forecasting.forecast with(nolock)
      			where
      			BusinessDay = CONVERT(VARCHAR(10), getdate()+15, 121)
      			and GenerationDate > CONVERT(VARCHAR(10), getdate(), 121)
      			)
      	END
      END
      ;
      BEGIN
      IF @dayofweek = 'Monday'
      	BEGIN
      		SELECT '-------------------------------------------------------' AS 'Today is Monday - no Summary Forecasts for Sundays'
      	END
      ELSE
      	BEGIN
      		Select COUNT(1) AS SummaryForecastsNotImported
      		from tbentityzone ez with(nolock)
      				join tbentity e with(nolock) on ez.entityid = e.entityid
      				where ez.ZoneID = 770
      				AND e.Status != 'Closed'
      				and e.TempCloseDate is Null
      				AND ez.EntityID not in (
      					select EntityID from Forecasting.forecast with(nolock)
      					where
      					BusinessDay = CONVERT(VARCHAR(10), getdate()+20, 121)
      					and GenerationDate > CONVERT(VARCHAR(10), getdate(), 121)
      					)
      	END
      END
      ;
      SELECT '-----------------------------------------------------------------------------' AS 'Count of Forecasts Proccessed by Business Date'
      ;
      SELECT 
      COUNT(1) AS ForecastCount,
      SUBSTRING(a.AuditDetails, 117, 10) AS BusinessDay 
      FROM tbAudit a WITH (NOLOCK) 
      WHERE a.AuditDateTime >= CONVERT(VARCHAR(10), getdate(), 121)
      AND a.AuditDateTime < CONVERT(VARCHAR(10), getdate()+1, 121)
      AND a.AuditCategoryID = 23 
      AND a.AuditDetails LIKE '%demand%'
      GROUP BY SUBSTRING(a.AuditDetails, 117, 10)
      ;
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Gareth.Leibbrandt Gareth Leibbrandt (Inactive)
                Reporter:
                will.englefield Will Englefield (Inactive)
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 18h
                  18h

                    PagerDuty

                    Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.