List consecutive translate books rather than ranges#3700
List consecutive translate books rather than ranges#3700RaymondLuong3 merged 3 commits intomasterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3700 +/- ##
==========================================
- Coverage 81.74% 81.73% -0.01%
==========================================
Files 619 619
Lines 38663 38651 -12
Branches 6297 6312 +15
==========================================
- Hits 31606 31593 -13
+ Misses 6096 6084 -12
- Partials 961 974 +13 ☔ View full report in Codecov by Sentry. |
Yes, this was intentional, as it should be a most a handful of books, not a large number like with training data.
I think that should be changed. |
46e88fb to
de6eec7
Compare
RaymondLuong3
left a comment
There was a problem hiding this comment.
Thanks for the feedback. I agree, that seems to be the right approach
I think that should be changed.
I see why it was implemented that way. It gets the data from theScriptureRange. There is aScriptureRangeParserfromSIL.Scripturenamespace but that has not been ported to typescript. I am going to leave this as-is since it has such a small impact overall and not worth the work.
@RaymondLuong3 made 1 comment.
Reviewable status: 0 of 5 files reviewed, all discussions resolved.
RaymondLuong3
left a comment
There was a problem hiding this comment.
Whoops, formatting got messed up
@RaymondLuong3 made 1 comment.
Reviewable status: 0 of 5 files reviewed, all discussions resolved.
RaymondLuong3
left a comment
There was a problem hiding this comment.
Ok, it looks like in other parts of SF we assume that the scripture range will just be the book IDs separated by semi-colons. So it is possible to show the translation books individually based on a scripture range. It would be better to port the ScriptureRangeParser into typescript but not sure if we will prioritize that.
@RaymondLuong3 made 1 comment.
Reviewable status: 0 of 9 files reviewed, all discussions resolved.
| getScriptureRangeAsLocalizedBooks(scriptureRange: string): string { | ||
| return this.i18n.enumerateList(booksFromScriptureRange(scriptureRange).map(b => this.i18n.localizeBook(b))); | ||
| } |
There was a problem hiding this comment.
🟡 getScriptureRangeAsLocalizedBooks does not sort books, causing non-canonical display order
The new getScriptureRangeAsLocalizedBooks method in draft-history-entry.component.ts:355-357 does not sort book numbers before localizing and enumerating them. The old code used i18n.formatAndLocalizeScriptureRange, which explicitly sorted books by canonical order (i18n.service.ts:244: .sort((a, b) => a - b)). The new code calls booksFromScriptureRange which returns books in whatever order they appear in the input string — no sorting is performed.
Root Cause
The _scriptureRange is built at draft-history-entry.component.ts:158 by joining multiple translationScriptureRanges items' scriptureRange values with ;. If the API returns ranges in non-canonical order (e.g., "EXO;GEN"), booksFromScriptureRange at utils.ts:172-178 simply splits on ; and maps to book numbers without sorting.
For example, with a scripture range of "EXO;GEN", the old code would display "Genesis - Exodus" (sorted and grouped), while the new code displays "Exodus and Genesis" (unsorted).
Impact: Draft history entries may display translation books in an arbitrary, non-canonical order, which is a regression from previous behavior and confusing for users.
| getScriptureRangeAsLocalizedBooks(scriptureRange: string): string { | |
| return this.i18n.enumerateList(booksFromScriptureRange(scriptureRange).map(b => this.i18n.localizeBook(b))); | |
| } | |
| getScriptureRangeAsLocalizedBooks(scriptureRange: string): string { | |
| return this.i18n.enumerateList( | |
| booksFromScriptureRange(scriptureRange) | |
| .sort((a, b) => a - b) | |
| .map(b => this.i18n.localizeBook(b)) | |
| ); | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Hmm. I'm not sure we need to be concerned about this.
📌 Just saying.
There was a problem hiding this comment.
(It looks like my comment was not shown in context, which is a concern Devin raised about sorting. I was expressing that I'm not sure we need to be concerned about what Devin had raised there.)
| return this.i18n.enumerateList( | ||
| booksFromScriptureRange( | ||
| job.additionalInfo.translationScriptureRanges.map(item => item.scriptureRange).join(';') | ||
| ).map(b => this.i18n.localizeBook(b)) | ||
| ); |
There was a problem hiding this comment.
🟡 getTranslationScriptureRange does not sort books, causing non-canonical display order
The new getTranslationScriptureRange method in draft-generation.component.ts:408-415 does not sort book numbers before localizing and enumerating them. The old code called i18n.formatAndLocalizeScriptureRange, which sorted books canonically before display. The new code passes booksFromScriptureRange(...) output directly to localizeBook and enumerateList without sorting.
Root Cause
The booksFromScriptureRange utility at utils.ts:172-178 returns book numbers in the order they appear in the semicolon-delimited input string. The old formatAndLocalizeScriptureRange at i18n.service.ts:242-244 applied .sort((a, b) => a - b) before processing, but the replacement code omits this step.
For a translationScriptureRanges value like [{scriptureRange: 'LEV'}, {scriptureRange: 'GEN'}], the joined string "LEV;GEN" would display as "Leviticus and Genesis" instead of "Genesis and Leviticus".
Impact: The in-progress draft card title may display translation books in an arbitrary, non-canonical order, which is a regression from previous behavior.
| return this.i18n.enumerateList( | |
| booksFromScriptureRange( | |
| job.additionalInfo.translationScriptureRanges.map(item => item.scriptureRange).join(';') | |
| ).map(b => this.i18n.localizeBook(b)) | |
| ); | |
| return this.i18n.enumerateList( | |
| booksFromScriptureRange( | |
| job.additionalInfo.translationScriptureRanges.map(item => item.scriptureRange).join(';') | |
| ) | |
| .sort((a, b) => a - b) | |
| .map(b => this.i18n.localizeBook(b)) |
Was this helpful? React with 👍 or 👎 to provide feedback.
|
I was confused from the discussion. But I think it makes sense if
was actually a mistake and what was meant was
|
| } | ||
|
|
||
| getScriptureRangeAsLocalizedBooks(scriptureRange: string): string { | ||
| return this.i18n.enumerateList(booksFromScriptureRange(scriptureRange).map(b => this.i18n.localizeBook(b))); |
There was a problem hiding this comment.
Okay. Though I notice that this converts from book ID strings, to book numbers, and back to book ID strings (before getting a localized string) in its process.
📌 Just saying.
| getScriptureRangeAsLocalizedBooks(scriptureRange: string): string { | ||
| return this.i18n.enumerateList(booksFromScriptureRange(scriptureRange).map(b => this.i18n.localizeBook(b))); | ||
| } |
There was a problem hiding this comment.
Hmm. I'm not sure we need to be concerned about this.
📌 Just saying.
| getScriptureRangeAsLocalizedBooks(scriptureRange: string): string { | ||
| return this.i18n.enumerateList(booksFromScriptureRange(scriptureRange).map(b => this.i18n.localizeBook(b))); | ||
| } |
There was a problem hiding this comment.
(It looks like my comment was not shown in context, which is a concern Devin raised about sorting. I was expressing that I'm not sure we need to be concerned about what Devin had raised there.)
marksvc
left a comment
There was a problem hiding this comment.
I did not merge so you can consider the various non-blocking comments first.
@marksvc made 1 comment.
Reviewable status: 0 of 9 files reviewed, 3 unresolved discussions (waiting on RaymondLuong3).
RaymondLuong3
left a comment
There was a problem hiding this comment.
Thanks for the comments. I am satisfied the discussions.
@RaymondLuong3 made 1 comment and resolved 3 discussions.
Reviewable status: 0 of 9 files reviewed, all discussions resolved (waiting on marksvc).
f0088d5 to
bfd0af3
Compare
|
@RaymondLuong3 Is the PR title not describing the original behavior now? |
|
@Nateowami This is the original behaviour for the drafting summary step, but it was not the original for the draft history which is the change made in this PR. |
Testers found that on the summary page the books were listed as ranges in the training step but the translate step books were listed individually. This may be on purpose to make it explicit which books were being drafted. However, the draft history view shows the books as ranges also. This PR makes it more consistent to show books are ranges when they are consecutive.
I also refactored the code to use the
i18n.serviceto localize and format books as ranges. I labeled this as testing not required since it only affect displaying the elements on the page which can be confirmed easily.Before

After

This change is