From a5ffc69b21e84ebbfe68ea6b84523197f2fdee71 Mon Sep 17 00:00:00 2001 From: Auldrin Possa Date: Thu, 24 Apr 2025 12:34:52 +0100 Subject: [PATCH] TD-5447- FrameworkCompetencyGroupID null check added in the SQL query and in the stored procedure. Migration script added to update ordering for existing ungroup competencies. --- ...241045_Alter_ReorderFrameworkCompetency.cs | 19 ++++++++ ...115_UpdateFrameworkCompetenciesOrdering.cs | 21 +++++++++ .../Properties/Resources.Designer.cs | 44 ++++++++++++++++++ .../Properties/Resources.resx | 6 +++ ...-Alter_ReorderFrameworkCompetency_Down.sql | Bin 0 -> 5404 bytes ...47-Alter_ReorderFrameworkCompetency_Up.sql | Bin 0 -> 6644 bytes .../DataServices/FrameworkDataService.cs | 10 ++-- 7 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 DigitalLearningSolutions.Data.Migrations/202504241045_Alter_ReorderFrameworkCompetency.cs create mode 100644 DigitalLearningSolutions.Data.Migrations/202504241115_UpdateFrameworkCompetenciesOrdering.cs create mode 100644 DigitalLearningSolutions.Data.Migrations/Scripts/TD-5447-Alter_ReorderFrameworkCompetency_Down.sql create mode 100644 DigitalLearningSolutions.Data.Migrations/Scripts/TD-5447-Alter_ReorderFrameworkCompetency_Up.sql diff --git a/DigitalLearningSolutions.Data.Migrations/202504241045_Alter_ReorderFrameworkCompetency.cs b/DigitalLearningSolutions.Data.Migrations/202504241045_Alter_ReorderFrameworkCompetency.cs new file mode 100644 index 0000000000..f4530aa7f9 --- /dev/null +++ b/DigitalLearningSolutions.Data.Migrations/202504241045_Alter_ReorderFrameworkCompetency.cs @@ -0,0 +1,19 @@ + + +namespace DigitalLearningSolutions.Data.Migrations +{ + using FluentMigrator; + + [Migration(202504241045)] + public class Alter_ReorderFrameworkCompetency : Migration + { + public override void Up() + { + Execute.Sql(Properties.Resources.TD_5447_Alter_ReorderFrameworkCompetency_Up); + } + public override void Down() + { + Execute.Sql(Properties.Resources.TD_5447_Alter_ReorderFrameworkCompetency_Down); + } + } +} diff --git a/DigitalLearningSolutions.Data.Migrations/202504241115_UpdateFrameworkCompetenciesOrdering.cs b/DigitalLearningSolutions.Data.Migrations/202504241115_UpdateFrameworkCompetenciesOrdering.cs new file mode 100644 index 0000000000..aec171d621 --- /dev/null +++ b/DigitalLearningSolutions.Data.Migrations/202504241115_UpdateFrameworkCompetenciesOrdering.cs @@ -0,0 +1,21 @@ +namespace DigitalLearningSolutions.Data.Migrations +{ + using FluentMigrator; + [Migration(202504241115)] + public class UpdateFrameworkCompetenciesOrdering : ForwardOnlyMigration + { + public override void Up() + { + Execute.Sql(@"WITH Ranked AS ( +    SELECT ID, +            ROW_NUMBER() OVER (PARTITION BY FrameworkID ORDER BY SysStartTime) AS NewOrder +    FROM FrameworkCompetencies + Where FrameworkCompetencyGroupID is null + ) + UPDATE fc + SET fc.Ordering = r.NewOrder + FROM FrameworkCompetencies fc + JOIN Ranked r ON fc.ID = r.ID;"); + } + } +} diff --git a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs index 1b4edf4c6f..d49dcbba16 100644 --- a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs +++ b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs @@ -2436,6 +2436,50 @@ internal static string TD_5412_Alter_SendExpiredTBCReminders_Up { } } + /// + /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[ReorderFrameworkCompetency] Script Date: 24/04/2025 09:23:17 ******/ + ///SET ANSI_NULLS ON + ///GO + /// + ///SET QUOTED_IDENTIFIER ON + ///GO + /// + ///-- ============================================= + ///-- Author: Kevin Whittaker + ///-- Create date: 04/01/2021 + ///-- Description: Reorders the FrameworkCompetencies in a given FrameworkCompetencyGroup - moving the given competency up or down. + ///-- ============================================= + ///ALTER PROCEDURE [dbo].[ReorderFrameworkCompetency] + /// [rest of string was truncated]";. + /// + internal static string TD_5447_Alter_ReorderFrameworkCompetency_Down { + get { + return ResourceManager.GetString("TD_5447_Alter_ReorderFrameworkCompetency_Down", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[ReorderFrameworkCompetency] Script Date: 24/04/2025 09:23:17 ******/ + ///SET ANSI_NULLS ON + ///GO + /// + ///SET QUOTED_IDENTIFIER ON + ///GO + /// + ///-- ============================================= + ///-- Author: Kevin Whittaker + ///-- Create date: 04/01/2021 + ///-- Description: Reorders the FrameworkCompetencies in a given FrameworkCompetencyGroup - moving the given competency up or down. + ///-- ============================================= + ///ALTER PROCEDURE [dbo].[ReorderFrameworkCompetency] + /// [rest of string was truncated]";. + /// + internal static string TD_5447_Alter_ReorderFrameworkCompetency_Up { + get { + return ResourceManager.GetString("TD_5447_Alter_ReorderFrameworkCompetency_Up", resourceCulture); + } + } + /// /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[GetActiveAvailableCustomisationsForCentreFiltered_V6] Script Date: 29/09/2022 19:11:04 ******/ ///SET ANSI_NULLS ON diff --git a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx index a951c296c9..00db99e650 100644 --- a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx +++ b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx @@ -475,4 +475,10 @@ ..\Scripts\TD-5412-Alter_SendExpiredTBCReminders_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + + ..\Scripts\TD-5447-Alter_ReorderFrameworkCompetency_Down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + + + ..\Scripts\TD-5447-Alter_ReorderFrameworkCompetency_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + \ No newline at end of file diff --git a/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5447-Alter_ReorderFrameworkCompetency_Down.sql b/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5447-Alter_ReorderFrameworkCompetency_Down.sql new file mode 100644 index 0000000000000000000000000000000000000000..56bac72b67185f300a00e14ae970694687d73d1a GIT binary patch literal 5404 zcmeI0>rWFw6vgk?n)pBLH$XrhYK$m`+5!@RB9CBVjNwtBLR-=ngnwTBotZA%Z3kE$ zg@l;RcJI#2ow;-Fxo0Q+`)ABvbX<{@Y}f_@)P*ZQ{7$_Vtir^S$3Hykq7C3 zSC5F5g`PA~*wpzI7OF$BS4vj4GoC^;ay?BrcI0}R^tIaP3cqT5zrIRU#~%MZ#;N9N z)I|g%754#_B3tAxxOkKiU&+#3`8M0k&AE|^IkboOZdL8yb58Xm4O?IiMc81b2&;GY zgcaB4U;0@f+I*YES^1FEwP%L1v);xj%bZ!f3S^|=awF7M$b=Z5UP;_Lay*l&&Daw5 zS#WGRE4SUJSbS6E(_TkhbiJM)hw!Y4Ul<8_mB7b;*JB>eIc-|X7-y{UoAwzdcqL0> z%8HUayq}iP=)Tur4e_J{VIe*yYYL~IYj!_>m529b#q_43eA1Jug6Sh z7tIh-Q_Veqwyp5%&r6DPhMEo4#z*=lQscrJt6BXCBCV}jr$~PEt;>c+%%50|yR+(b z|FU>HSvMF!|7s?xSFDM%7n!7njU9+hOejBy!83uKezpP`{o%<>)KtoJ^X0g9)47A z_d}=0U6nnIPWLKU2+xqtUd=Z3rulRmwe6=;d!-3|Rr{;aPg{o{m%E|w+*9PPPJQ7M UR)4wM{bj!I^F(s8i2n)v2Qm#|<^TWy literal 0 HcmV?d00001 diff --git a/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5447-Alter_ReorderFrameworkCompetency_Up.sql b/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5447-Alter_ReorderFrameworkCompetency_Up.sql new file mode 100644 index 0000000000000000000000000000000000000000..cc17b6815264d89cf500866d40ed2031290b306c GIT binary patch literal 6644 zcmeI1>rWFw6vgjXO#C1Ao1h{OHO2>q+M+fBMbThljNwrMfkN7X@XxEiGt*%o9qUpB zF_KL?vom{V?wot>nc4RHw+XwMxe{yGntidRty|X~S;DnUZQt6oZP*g!K7Fbmy0*kV zP+z08aQv^}2ncd}s4q%d|GQ z(^D^~smxlu=D7y8b9nLz%Nn&s?(3|pPW{bK?8j}Ko|$vIj(r}c(6jxHvL_2+@ZbgR_86N+%%+EDjGLFhL&xEesKDDjE2aP3V@~lgU%aQYR z9j3|SQS@O9+ZjGLxKit7$E;1;Wdtc&)3IcY)~=hOLaV%d2EH%IZm$XfpP(U&E)osm zARX}PkubB+lO_tAeZGZ-@=)xRk~Qs^Qivw5rvt}!T~CL;ZVz4Ix7S;*&r;>F$Nw|W zDd$?`MFJz`_ZBsIHqWQ({82=FCQEZ=+vzcP#62mWV{3TqX4U#V=afIvusUPN!!{!& z)cQwHS@G-mOFyf4Tj{a5EFaRm_RLUp-u7@RGiDj9DiLYB*a)>HA|b}-XA<{z9nYj{ zv$jC}IQncpD#NZ*EIzC9X|1=Ncm0+ghxn+eT^tEnHNeO3>w$;Qoi;6$^fPGuioJvh zUdd9Q%AzC-uO~&6^YM_!3vlf{s!;S?8u9zS4?;M$8oySZL!@t`L&er>TWs{$$*Pz+ z4NxC`<~kZ8{qUzJf1=V#hV>>t-Wba5(K`2kp{&8=OTw`hV%U*i0^-S