fix(seed): remap seed LanguageId to real SDK ids for AreaRuleTranslations#985
Merged
Merged
Conversation
…ions New tenants stored placeholder-keyed (1/2/3) area-rule name translations that don't match the SDK Languages auto-increment ids, breaking calendar event titles. Mirror the #982 AreaTranslation fix: resolve the real SDK language id by LanguageCode before each areaRule.Create at all seed write paths (default rules x2, area-1 re-seed, Type7/Type8 build). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes seeded AreaRuleTranslation.LanguageId values by remapping the seed’s hardcoded IDs (1/2/3) to the tenant’s real SDK Languages.Id resolved by LanguageCode, ensuring area-rule name translations match the worker/site language selection introduced in #983 and preventing empty calendar event titles.
Changes:
- Added
AreaRuleLanguageHelperto remap seed language IDs to real SDK language IDs by code. - Applied remapping to seeded area-rule creation paths (property-area seed loops, area-1 reseed, and Type7/Type8 translation builds).
- Updated the Type10 “Morgenrundtur” rule translation seeding to build a translation list and remap IDs prior to persisting.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/BackendConfigurationAreaRulesService/BackendConfigurationAreaRulesService.cs | Remaps seed language IDs when creating seeded area rules/translations (incl. Type10 “Morgenrundtur” translations and area-1 reseed). |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/BackendConfigurationPropertyAreasServiceHelper.cs | Remaps seed language IDs for area rules created during property-area activation seeding. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/BackendConfigurationAreaRulesServiceHelper.cs | Remaps seed language IDs for Type7/Type8 translation lists generated from seed data. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/AreaRuleLanguageHelper.cs | New helper that resolves SDK language IDs by code and mutates translations in-place. |
Comment on lines
+21
to
+31
| var sdkLanguages = await sdkDbContext.Languages.ToListAsync().ConfigureAwait(false); | ||
| var seedLanguageIdToCode = new Dictionary<int, string> { { 1, "da" }, { 2, "en-US" }, { 3, "de-DE" } }; | ||
| var seedLanguageIdToSdkId = new Dictionary<int, int>(); | ||
| foreach (var (seedLanguageId, code) in seedLanguageIdToCode) | ||
| { | ||
| var lang = sdkLanguages.FirstOrDefault(x => x.LanguageCode == code); | ||
| if (lang != null) | ||
| { | ||
| seedLanguageIdToSdkId[seedLanguageId] = lang.Id; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Calendar event titles (
taskText) come fromAreaRuleTranslations(copied verbatim intoPlanningNameTranslation). Those rows are seeded fromBackendConfigurationSeedAreas.AreaRules/AreaRulesForType7/8(and a Type10 "Morgenrundtur" path), which hardcodeLanguageId = 1/2/3. But each tenant's SDKLanguagestable uses environment-specific auto-increment ids (e.g. da=2, en-US=5, de-DE=8 — id 1 may not exist).Commit #983 made the gRPC title lookup strict by the worker's real Site language id, so placeholder-keyed rows stop matching → empty event titles in the mobile app (observed on tenant 1124).
PR #982 fixed this exact pattern for
AreaTranslationsinSeedEForms, but leftAreaRuleTranslationsun-remapped — this PR closes that gap.Fix
New
AreaRuleLanguageHelper.RemapSeedLanguageIdsAsync(...)resolves the real SDK id byLanguageCode(map{1→da, 2→en-US, 3→de-DE}) and in-place re-keys translations before persist. Applied at every area-rule creation site that used raw seed ids:BackendConfigurationPropertyAreasServiceHelper(×2 seeded-default loops)BackendConfigurationAreaRulesService(area-1 re-seed + Type10 Morgenrundtur)BackendConfigurationAreaRulesServiceHelper(Type7/Type8 translation lists)Frontend-sourced paths (already real SDK ids) are left untouched.
PlanningNameTranslationinherits the fix automatically (it copiesAreaRuleTranslation.LanguageIdverbatim).Safe for all tenants: the map keys are seed ids; values resolve by language code, so even tenants whose real ids happen to be 1/2/3 (e.g. 1116) get an identity write — no corruption. Existing broken data is repaired separately (data fix, out of scope here).
🤖 Generated with Claude Code