From fa12e930f3051cc17c010d8d0f0ffc4210a1a364 Mon Sep 17 00:00:00 2001 From: Ioan Popovici Date: Fri, 2 Feb 2024 18:54:01 +0200 Subject: [PATCH] Released v5.0.5 # Changelog for MEM.Zone-Dashboards ## 5.0.5 - 2024-02-02 * Fixed variable bug `Next Maintenance Window` if using `Offset Days` maintenance windows (issue #31). --- .../Extensions/ufn_CM_GetNextMaintenanceWindow.sql | 8 ++++---- docs/CHANGELOG.md | 4 ++++ .../Extensions/ufn_CM_GetNextMaintenanceWindow.sql | 8 ++++---- src/MEM.Zone-Dashboards/docs/CHANGELOG.md | 4 ++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql b/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql index 0945548..2fb42b9 100644 --- a/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql +++ b/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql @@ -168,14 +168,14 @@ AS -- Calculate the next interval DECLARE @WeeklyNextInterval DATETIME; SET @WeeklyNextInterval = DATEADD(WEEK, @WeeklyNumberOfCompletedIntervals * @WeeklyInterval, @WeeklyStartTime) - -- Recalc the next interval if the next interval plus the expected duration is in the past + -- Recalculate the next interval if the next interval plus the expected duration is in the past IF DATEADD(MINUTE, @Duration, @WeeklyNextInterval) < @Now BEGIN SET @WeeklyNextInterval = DATEADD(WEEK, (@WeeklyNumberOfCompletedIntervals + 1) * @WeeklyInterval, @WeeklyStartTime) END SET @NextMaintenanceWindow = @WeeklyNextInterval END - END ELSE IF @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAY OR @RecurrenceType = RecurrenceType_MONTHLYBYWEEKDAYBASE BEGIN + END ELSE IF @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAY OR @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAYBASE BEGIN DECLARE @MonthlyBWWeek INT; SET @MonthlyBWWeek = (@ScheduleDuration / POWER(2,9)) % POWER(2, 3) DECLARE @MontlhyBWInterval INT; SET @MontlhyBWInterval = (@ScheduleDuration / POWER(2,12)) % POWER(2, 4) DECLARE @MonthlyBWDoW INT; SET @MonthlyBWDoW = (@ScheduleDuration / POWER(2,16)) % POWER(2, 3) @@ -194,7 +194,7 @@ AS SET @MonthlyBWLDOMNextInterval = DATEADD(DAY, -(7 - DATEPART(WEEKDAY, @MonthlyBWLDOMNextInterval) + @MonthlyBWDoW % 7), @MonthlyBWLDOMNextInterval) IF DATEADD(MINUTE, @Duration, @MonthlyBWLDOMNextInterval) < @Now BEGIN - -- Recalc for the next month interval + -- Recalculate for the next month interval SET @MonthlyBWLDOMNextInterval = DATEADD(MONTH, (@MonthlyBWNumberOfCompletedIntervals + 1) * @MontlhyBWInterval, @StartTime) -- Calculate last day of month @@ -219,7 +219,7 @@ AS SET @MonthlyBWNextInterval = DATEADD(WEEK, @MonthlyBWWeek-1, @MonthlyBWNextInterval) IF DATEADD(MINUTE, @Duration, @MonthlyBWNextInterval) < @Now BEGIN - -- Recalc for the next month interval + -- Recalculate for the next month interval SET @MonthlyBWNextInterval = DATEADD(MONTH, (@MonthlyBWNumberOfCompletedIntervals + 1) * @MontlhyBWInterval, @StartTime) -- Set the date to the first day of the month diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e70b78b..424c0ff 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for MEM.Zone-Dashboards +## 5.0.5 - 2024-02-02 + +* Fixed variable bug `Next Maintenance Window` if using `Offset Days` maintenance windows (issue #31). + ## 5.0.4 - 2024-01-30 * Fixed `Next Maintenance Window` if using `Offset Days` maintenance windows #31. diff --git a/src/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql b/src/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql index 0945548..2fb42b9 100644 --- a/src/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql +++ b/src/MEM.Zone-Dashboards/Extensions/ufn_CM_GetNextMaintenanceWindow.sql @@ -168,14 +168,14 @@ AS -- Calculate the next interval DECLARE @WeeklyNextInterval DATETIME; SET @WeeklyNextInterval = DATEADD(WEEK, @WeeklyNumberOfCompletedIntervals * @WeeklyInterval, @WeeklyStartTime) - -- Recalc the next interval if the next interval plus the expected duration is in the past + -- Recalculate the next interval if the next interval plus the expected duration is in the past IF DATEADD(MINUTE, @Duration, @WeeklyNextInterval) < @Now BEGIN SET @WeeklyNextInterval = DATEADD(WEEK, (@WeeklyNumberOfCompletedIntervals + 1) * @WeeklyInterval, @WeeklyStartTime) END SET @NextMaintenanceWindow = @WeeklyNextInterval END - END ELSE IF @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAY OR @RecurrenceType = RecurrenceType_MONTHLYBYWEEKDAYBASE BEGIN + END ELSE IF @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAY OR @RecurrenceType = @RecurrenceType_MONTHLYBYWEEKDAYBASE BEGIN DECLARE @MonthlyBWWeek INT; SET @MonthlyBWWeek = (@ScheduleDuration / POWER(2,9)) % POWER(2, 3) DECLARE @MontlhyBWInterval INT; SET @MontlhyBWInterval = (@ScheduleDuration / POWER(2,12)) % POWER(2, 4) DECLARE @MonthlyBWDoW INT; SET @MonthlyBWDoW = (@ScheduleDuration / POWER(2,16)) % POWER(2, 3) @@ -194,7 +194,7 @@ AS SET @MonthlyBWLDOMNextInterval = DATEADD(DAY, -(7 - DATEPART(WEEKDAY, @MonthlyBWLDOMNextInterval) + @MonthlyBWDoW % 7), @MonthlyBWLDOMNextInterval) IF DATEADD(MINUTE, @Duration, @MonthlyBWLDOMNextInterval) < @Now BEGIN - -- Recalc for the next month interval + -- Recalculate for the next month interval SET @MonthlyBWLDOMNextInterval = DATEADD(MONTH, (@MonthlyBWNumberOfCompletedIntervals + 1) * @MontlhyBWInterval, @StartTime) -- Calculate last day of month @@ -219,7 +219,7 @@ AS SET @MonthlyBWNextInterval = DATEADD(WEEK, @MonthlyBWWeek-1, @MonthlyBWNextInterval) IF DATEADD(MINUTE, @Duration, @MonthlyBWNextInterval) < @Now BEGIN - -- Recalc for the next month interval + -- Recalculate for the next month interval SET @MonthlyBWNextInterval = DATEADD(MONTH, (@MonthlyBWNumberOfCompletedIntervals + 1) * @MontlhyBWInterval, @StartTime) -- Set the date to the first day of the month diff --git a/src/MEM.Zone-Dashboards/docs/CHANGELOG.md b/src/MEM.Zone-Dashboards/docs/CHANGELOG.md index e70b78b..424c0ff 100644 --- a/src/MEM.Zone-Dashboards/docs/CHANGELOG.md +++ b/src/MEM.Zone-Dashboards/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for MEM.Zone-Dashboards +## 5.0.5 - 2024-02-02 + +* Fixed variable bug `Next Maintenance Window` if using `Offset Days` maintenance windows (issue #31). + ## 5.0.4 - 2024-01-30 * Fixed `Next Maintenance Window` if using `Offset Days` maintenance windows #31.