diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs index fcb98bba8..11e0b76ba 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs @@ -68,6 +68,9 @@ protected override IQueryable Filter(FilteringHeader s.NameGerman.Contains(filtering.Filter.NameGerman)); + if (filtering.Filter.IsInFlemishRegion.HasValue) + streetNames = streetNames.Where(x => x.IsInFlemishRegion); + var filterMunicipalityName = filtering.Filter.MunicipalityName.RemoveDiacritics(); if (!string.IsNullOrEmpty(filtering.Filter.MunicipalityName)) { @@ -156,5 +159,7 @@ public sealed class StreetNameFilter public string Status { get; set; } = string.Empty; public string? NisCode { get; set; } = string.Empty; public string? PostalCode { get; set; } = string.Empty; + + public bool? IsInFlemishRegion { get; set; } = null; } } diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs index 2270e9845..b4df9dcb5 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs @@ -78,6 +78,11 @@ protected override IQueryable Filter(FilteringHeader s.NameGerman.Contains(filtering.Filter.NameGerman)); } + if (filtering.Filter.IsInFlemishRegion.HasValue) + { + streetNames = streetNames.Where(x => x.IsInFlemishRegion); + } + var filterMunicipalityName = filtering.Filter.MunicipalityName.RemoveDiacritics(); if (!string.IsNullOrEmpty(filtering.Filter.MunicipalityName)) { @@ -165,5 +170,6 @@ public class StreetNameFilter public string Status { get; set; } public string? NisCode { get; set; } public string? PostalCode { get; set; } + public bool? IsInFlemishRegion { get; set; } = null; } } diff --git a/src/StreetNameRegistry.Projections.Legacy/Migrations/20230929115231_AddIsInFlemishRegion_List.Designer.cs b/src/StreetNameRegistry.Projections.Legacy/Migrations/20230929115231_AddIsInFlemishRegion_List.Designer.cs new file mode 100644 index 000000000..ec1190e26 --- /dev/null +++ b/src/StreetNameRegistry.Projections.Legacy/Migrations/20230929115231_AddIsInFlemishRegion_List.Designer.cs @@ -0,0 +1,655 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using StreetNameRegistry.Projections.Legacy; + +#nullable disable + +namespace StreetNameRegistry.Projections.Legacy.Migrations +{ + [DbContext(typeof(LegacyContext))] + [Migration("20230929115231_AddIsInFlemishRegion_List")] + partial class AddIsInFlemishRegion_List + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.ProjectionStates.ProjectionStateItem", b => + { + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("DesiredState") + .HasColumnType("nvarchar(max)"); + + b.Property("DesiredStateChangedAt") + .HasColumnType("datetimeoffset"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Position") + .HasColumnType("bigint"); + + b.HasKey("Name"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Name")); + + b.ToTable("ProjectionStates", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameDetail.StreetNameDetail", b => + { + b.Property("StreetNameId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Complete") + .HasColumnType("bit"); + + b.Property("HomonymAdditionDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NisCode") + .HasColumnType("nvarchar(max)"); + + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("Removed") + .HasColumnType("bit"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("VersionTimestamp"); + + b.HasKey("StreetNameId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("StreetNameId"), false); + + b.HasIndex("PersistentLocalId") + .IsUnique() + .HasDatabaseName("IX_StreetNameDetails_PersistentLocalId_1") + .HasFilter("([PersistentLocalId] IS NOT NULL)"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("PersistentLocalId"), false); + + b.HasIndex("Removed"); + + b.ToTable("StreetNameDetails", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameDetailV2.StreetNameDetailV2", b => + { + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("HomonymAdditionDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("LastEventHash") + .HasColumnType("nvarchar(max)"); + + b.Property("MunicipalityId") + .HasColumnType("uniqueidentifier"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NisCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Removed") + .HasColumnType("bit"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("VersionTimestamp"); + + b.HasKey("PersistentLocalId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("PersistentLocalId")); + + b.HasIndex("MunicipalityId"); + + b.HasIndex("Removed"); + + b.ToTable("StreetNameDetailsV2", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameList.StreetNameListItem", b => + { + b.Property("StreetNameId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Complete") + .HasColumnType("bit"); + + b.Property("HomonymAdditionDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("NameDutchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("NameEnglishSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("NameFrenchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NameGermanSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NisCode") + .HasColumnType("nvarchar(450)"); + + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("PrimaryLanguage") + .HasColumnType("int"); + + b.Property("Removed") + .HasColumnType("bit"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("VersionTimestamp"); + + b.HasKey("StreetNameId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("StreetNameId"), false); + + b.HasIndex("NameDutchSearch"); + + b.HasIndex("NameEnglishSearch"); + + b.HasIndex("NameFrenchSearch"); + + b.HasIndex("NameGermanSearch"); + + b.HasIndex("NisCode"); + + b.HasIndex("PersistentLocalId") + .IsUnique() + .HasDatabaseName("IX_StreetNameList_PersistentLocalId_1") + .HasFilter("([PersistentLocalId] IS NOT NULL)"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("PersistentLocalId"), false); + + b.HasIndex("Status"); + + b.HasIndex("Complete", "Removed"); + + b.HasIndex("Complete", "Removed", "PersistentLocalId"); + + b.ToTable("StreetNameList", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameList.StreetNameListViewCount", b => + { + b.Property("Count") + .HasColumnType("bigint"); + + b.ToView("vw_StreetNameListIds", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameListV2.StreetNameListItemV2", b => + { + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("HomonymAdditionDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("IsInFlemishRegion") + .HasColumnType("bit"); + + b.Property("MunicipalityId") + .HasColumnType("uniqueidentifier"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("NameDutchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("NameEnglishSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("NameFrenchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NameGermanSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NisCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("PrimaryLanguage") + .HasColumnType("int"); + + b.Property("Removed") + .HasColumnType("bit"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("VersionTimestamp"); + + b.HasKey("PersistentLocalId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("PersistentLocalId")); + + b.HasIndex("IsInFlemishRegion"); + + b.HasIndex("MunicipalityId"); + + b.HasIndex("NameDutchSearch"); + + b.HasIndex("NameEnglishSearch"); + + b.HasIndex("NameFrenchSearch"); + + b.HasIndex("NameGermanSearch"); + + b.HasIndex("NisCode"); + + b.HasIndex("Removed"); + + b.HasIndex("Status"); + + b.ToTable("StreetNameListV2", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameListV2.StreetNameListMunicipality", b => + { + b.Property("MunicipalityId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("NisCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryLanguage") + .HasColumnType("int"); + + b.Property("SecondaryLanguage") + .HasColumnType("int"); + + b.HasKey("MunicipalityId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MunicipalityId")); + + b.ToTable("StreetNameListMunicipality", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameName.StreetNameName", b => + { + b.Property("StreetNameId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Complete") + .HasColumnType("bit"); + + b.Property("IsFlemishRegion") + .HasColumnType("bit"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameDutchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(450)"); + + b.Property("NameEnglishSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(450)"); + + b.Property("NameFrenchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(450)"); + + b.Property("NameGermanSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NisCode") + .HasColumnType("nvarchar(450)"); + + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("Removed") + .HasColumnType("bit"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("VersionTimestamp"); + + b.HasKey("StreetNameId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("StreetNameId"), false); + + b.HasIndex("NameDutch"); + + b.HasIndex("NameDutchSearch"); + + b.HasIndex("NameEnglish"); + + b.HasIndex("NameEnglishSearch"); + + b.HasIndex("NameFrench"); + + b.HasIndex("NameFrenchSearch"); + + b.HasIndex("NameGerman"); + + b.HasIndex("NameGermanSearch"); + + b.HasIndex("NisCode"); + + b.HasIndex("PersistentLocalId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("PersistentLocalId")); + + b.HasIndex("Status"); + + b.HasIndex("VersionTimestampAsDateTimeOffset"); + + b.HasIndex("Removed", "IsFlemishRegion", "Complete"); + + b.ToTable("StreetNameName", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameNameV2.StreetNameNameV2", b => + { + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("IsFlemishRegion") + .HasColumnType("bit"); + + b.Property("MunicipalityId") + .HasColumnType("uniqueidentifier"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameDutchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(450)"); + + b.Property("NameEnglishSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(450)"); + + b.Property("NameFrenchSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(450)"); + + b.Property("NameGermanSearch") + .HasColumnType("nvarchar(450)"); + + b.Property("NisCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Removed") + .HasColumnType("bit"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("VersionTimestampAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("VersionTimestamp"); + + b.HasKey("PersistentLocalId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("PersistentLocalId")); + + b.HasIndex("MunicipalityId"); + + b.HasIndex("NameDutch"); + + b.HasIndex("NameDutchSearch"); + + b.HasIndex("NameEnglish"); + + b.HasIndex("NameEnglishSearch"); + + b.HasIndex("NameFrench"); + + b.HasIndex("NameFrenchSearch"); + + b.HasIndex("NameGerman"); + + b.HasIndex("NameGermanSearch"); + + b.HasIndex("NisCode"); + + b.HasIndex("Status"); + + b.HasIndex("VersionTimestampAsDateTimeOffset"); + + b.HasIndex("Removed", "IsFlemishRegion"); + + b.ToTable("StreetNameNameV2", "StreetNameRegistryLegacy"); + }); + + modelBuilder.Entity("StreetNameRegistry.Projections.Legacy.StreetNameSyndication.StreetNameSyndicationItem", b => + { + b.Property("Position") + .HasColumnType("bigint"); + + b.Property("Application") + .HasColumnType("int"); + + b.Property("ChangeType") + .HasColumnType("nvarchar(max)"); + + b.Property("EventDataAsXml") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("HomonymAdditionGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("IsComplete") + .HasColumnType("bit"); + + b.Property("LastChangedOnAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("LastChangedOn"); + + b.Property("Modification") + .HasColumnType("int"); + + b.Property("MunicipalityId") + .HasColumnType("uniqueidentifier"); + + b.Property("NameDutch") + .HasColumnType("nvarchar(max)"); + + b.Property("NameEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("NameFrench") + .HasColumnType("nvarchar(max)"); + + b.Property("NameGerman") + .HasColumnType("nvarchar(max)"); + + b.Property("NisCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Operator") + .HasColumnType("nvarchar(max)"); + + b.Property("Organisation") + .HasColumnType("int"); + + b.Property("PersistentLocalId") + .HasColumnType("int"); + + b.Property("Reason") + .HasColumnType("nvarchar(max)"); + + b.Property("RecordCreatedAtAsDateTimeOffset") + .HasColumnType("datetimeoffset") + .HasColumnName("RecordCreatedAt"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StreetNameId") + .HasColumnType("uniqueidentifier"); + + b.Property("SyndicationItemCreatedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Position"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Position")); + + b.HasIndex("PersistentLocalId"); + + b.HasIndex("Position") + .HasDatabaseName("CI_StreetNameSyndication_Position") + .HasAnnotation("SqlServer:ColumnStoreIndex", ""); + + b.HasIndex("StreetNameId"); + + b.ToTable("StreetNameSyndication", "StreetNameRegistryLegacy"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/StreetNameRegistry.Projections.Legacy/Migrations/20230929115231_AddIsInFlemishRegion_List.cs b/src/StreetNameRegistry.Projections.Legacy/Migrations/20230929115231_AddIsInFlemishRegion_List.cs new file mode 100644 index 000000000..95c60e4f3 --- /dev/null +++ b/src/StreetNameRegistry.Projections.Legacy/Migrations/20230929115231_AddIsInFlemishRegion_List.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace StreetNameRegistry.Projections.Legacy.Migrations +{ + public partial class AddIsInFlemishRegion_List : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsInFlemishRegion", + schema: "StreetNameRegistryLegacy", + table: "StreetNameListV2", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.Sql( + "UPDATE StreetNameRegistryLegacy.StreetNameListV2 SET IsInFlemishRegion = 1 WHERE NisCode LIKE '1%' OR NisCode LIKE '3%' OR NisCode LIKE '4%' OR NisCode LIKE '7%' OR NisCode LIKE '23%' OR NisCode LIKE '24%'"); + + migrationBuilder.CreateIndex( + name: "IX_StreetNameListV2_IsInFlemishRegion", + schema: "StreetNameRegistryLegacy", + table: "StreetNameListV2", + column: "IsInFlemishRegion"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_StreetNameListV2_IsInFlemishRegion", + schema: "StreetNameRegistryLegacy", + table: "StreetNameListV2"); + + migrationBuilder.DropColumn( + name: "IsInFlemishRegion", + schema: "StreetNameRegistryLegacy", + table: "StreetNameListV2"); + } + } +} diff --git a/src/StreetNameRegistry.Projections.Legacy/Migrations/LegacyContextModelSnapshot.cs b/src/StreetNameRegistry.Projections.Legacy/Migrations/LegacyContextModelSnapshot.cs index 2e0d2bb9e..52d4f188d 100644 --- a/src/StreetNameRegistry.Projections.Legacy/Migrations/LegacyContextModelSnapshot.cs +++ b/src/StreetNameRegistry.Projections.Legacy/Migrations/LegacyContextModelSnapshot.cs @@ -290,6 +290,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("HomonymAdditionGerman") .HasColumnType("nvarchar(max)"); + b.Property("IsInFlemishRegion") + .HasColumnType("bit"); + b.Property("MunicipalityId") .HasColumnType("uniqueidentifier"); @@ -338,6 +341,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("PersistentLocalId")); + b.HasIndex("IsInFlemishRegion"); + b.HasIndex("MunicipalityId"); b.HasIndex("NameDutchSearch"); diff --git a/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListProjectionsV2.cs b/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListProjectionsV2.cs index 9bbe98a18..829d66c6e 100755 --- a/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListProjectionsV2.cs +++ b/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListProjectionsV2.cs @@ -9,7 +9,6 @@ namespace StreetNameRegistry.Projections.Legacy.StreetNameListV2 using Municipality; using Municipality.Events; using NodaTime; - using StreetNameName = Municipality.StreetNameName; [ConnectedProjectionName("API endpoint lijst straatnamen")] [ConnectedProjectionDescription("Projectie die de straatnamen data voor de straatnamen lijst voorziet.")] @@ -28,6 +27,7 @@ await context.StreetNameListMunicipality.FindAsync(message.Message.MunicipalityI PersistentLocalId = message.Message.PersistentLocalId, MunicipalityId = message.Message.MunicipalityId, NisCode = message.Message.NisCode, + IsInFlemishRegion = RegionFilter.IsFlemishRegion(message.Message.NisCode), VersionTimestamp = message.Message.Provenance.Timestamp, Removed = message.Message.IsRemoved, PrimaryLanguage = municipality.PrimaryLanguage, @@ -53,6 +53,7 @@ await context.StreetNameListMunicipality.FindAsync(message.Message.MunicipalityI PersistentLocalId = message.Message.PersistentLocalId, MunicipalityId = message.Message.MunicipalityId, NisCode = message.Message.NisCode, + IsInFlemishRegion = RegionFilter.IsFlemishRegion(message.Message.NisCode), VersionTimestamp = message.Message.Provenance.Timestamp, Removed = false, PrimaryLanguage = municipality.PrimaryLanguage, @@ -260,9 +261,11 @@ await context.StreetNameListMunicipality.FindAsync(message.Message.MunicipalityI .Where(s => s.MunicipalityId == message.Message.MunicipalityId) .Union(context.StreetNameListV2.Where(s => s.MunicipalityId == message.Message.MunicipalityId)); + var streetNameIsInFlemishRegion = RegionFilter.IsFlemishRegion(message.Message.NisCode); foreach (var streetName in streetNames) { streetName.NisCode = message.Message.NisCode; + streetName.IsInFlemishRegion = streetNameIsInFlemishRegion; } }); diff --git a/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListV2.cs b/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListV2.cs index 7abf13036..3f0cb0c16 100755 --- a/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListV2.cs +++ b/src/StreetNameRegistry.Projections.Legacy/StreetNameListV2/StreetNameListV2.cs @@ -37,6 +37,8 @@ public sealed class StreetNameListItemV2 public string NisCode { get; set; } + public bool IsInFlemishRegion { get; set; } + private DateTimeOffset VersionTimestampAsDateTimeOffset { get; set; } public Instant VersionTimestamp @@ -88,6 +90,7 @@ public void Configure(EntityTypeBuilder builder) builder.Property(x => x.PrimaryLanguage); builder.Property(x => x.NisCode); + builder.Property(x => x.IsInFlemishRegion); builder.HasIndex(x => x.NisCode); builder.HasIndex(x => x.Status); @@ -99,7 +102,7 @@ public void Configure(EntityTypeBuilder builder) builder.HasIndex(x => x.MunicipalityId); builder.HasIndex(x => x.Removed); - + builder.HasIndex(x => x.IsInFlemishRegion); } } } diff --git a/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameListItemProjectionsV2Tests.cs b/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameListItemProjectionsV2Tests.cs index 6106fded7..5736877be 100644 --- a/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameListItemProjectionsV2Tests.cs +++ b/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameListItemProjectionsV2Tests.cs @@ -4,6 +4,7 @@ namespace StreetNameRegistry.Tests.ProjectionTests using System.Linq; using System.Threading.Tasks; using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Legacy; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using FluentAssertions; using global::AutoFixture; @@ -55,6 +56,7 @@ await Sut expectedStreetName.Should().NotBeNull(); expectedStreetName.MunicipalityId.Should().Be(streetNameWasProposedV2.MunicipalityId); expectedStreetName.NisCode.Should().Be(streetNameWasProposedV2.NisCode); + expectedStreetName.IsInFlemishRegion.Should().Be(RegionFilter.IsFlemishRegion(streetNameWasProposedV2.NisCode)); expectedStreetName.PersistentLocalId.Should().Be(streetNameWasProposedV2.PersistentLocalId); expectedStreetName.Removed.Should().BeFalse(); expectedStreetName.Status.Should().Be(StreetNameStatus.Proposed); @@ -88,6 +90,7 @@ await Sut expectedStreetName.Should().NotBeNull(); expectedStreetName.MunicipalityId.Should().Be(streetNameWasProposedV2.MunicipalityId); expectedStreetName.NisCode.Should().Be(streetNameWasProposedV2.NisCode); + expectedStreetName.IsInFlemishRegion.Should().Be(RegionFilter.IsFlemishRegion(streetNameWasProposedV2.NisCode)); expectedStreetName.PersistentLocalId.Should().Be(streetNameWasProposedV2.PersistentLocalId); expectedStreetName.Removed.Should().BeFalse(); expectedStreetName.Status.Should().Be(StreetNameStatus.Current); @@ -255,6 +258,7 @@ await Sut expectedStreetName.Should().NotBeNull(); expectedStreetName.MunicipalityId.Should().Be(streetNameWasProposedV2.MunicipalityId); expectedStreetName.NisCode.Should().Be(streetNameWasProposedV2.NisCode); + expectedStreetName.IsInFlemishRegion.Should().Be(RegionFilter.IsFlemishRegion(streetNameWasProposedV2.NisCode)); expectedStreetName.PersistentLocalId.Should().Be(streetNameWasProposedV2.PersistentLocalId); expectedStreetName.Removed.Should().BeFalse(); expectedStreetName.Status.Should().Be(StreetNameStatus.Rejected); @@ -327,6 +331,7 @@ await Sut expectedStreetName.Should().NotBeNull(); expectedStreetName.MunicipalityId.Should().Be(streetNameWasProposedV2.MunicipalityId); expectedStreetName.NisCode.Should().Be(streetNameWasProposedV2.NisCode); + expectedStreetName.IsInFlemishRegion.Should().Be(RegionFilter.IsFlemishRegion(streetNameWasProposedV2.NisCode)); expectedStreetName.PersistentLocalId.Should().Be(streetNameWasProposedV2.PersistentLocalId); expectedStreetName.Removed.Should().BeFalse(); expectedStreetName.Status.Should().Be(StreetNameStatus.Retired); @@ -437,6 +442,7 @@ await Sut expectedStreetName.Should().NotBeNull(); expectedStreetName.MunicipalityId.Should().Be(streetNameWasProposedV2.MunicipalityId); expectedStreetName.NisCode.Should().Be(streetNameWasProposedV2.NisCode); + expectedStreetName.IsInFlemishRegion.Should().Be(RegionFilter.IsFlemishRegion(streetNameWasProposedV2.NisCode)); expectedStreetName.PersistentLocalId.Should().Be(streetNameWasProposedV2.PersistentLocalId); expectedStreetName.Removed.Should().BeFalse(); expectedStreetName.Status.Should().Be(StreetNameStatus.Proposed); @@ -478,6 +484,7 @@ await Sut expectedStreetName.Should().NotBeNull(); expectedStreetName.MunicipalityId.Should().Be(streetNameWasProposedV2.MunicipalityId); expectedStreetName.NisCode.Should().Be(streetNameWasProposedV2.NisCode); + expectedStreetName.IsInFlemishRegion.Should().Be(RegionFilter.IsFlemishRegion(streetNameWasProposedV2.NisCode)); expectedStreetName.PersistentLocalId.Should().Be(streetNameWasProposedV2.PersistentLocalId); expectedStreetName.Removed.Should().BeFalse(); expectedStreetName.Status.Should().Be(StreetNameStatus.Proposed);