Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] StoryBook chapter number displayed incorrectly #1092

Closed
Keerthi4308 opened this issue Nov 10, 2020 · 9 comments
Closed

[Bug] StoryBook chapter number displayed incorrectly #1092

Keerthi4308 opened this issue Nov 10, 2020 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@Keerthi4308
Copy link

At http://eng.elimu.ai/content/storybook/edit/66 there seems to be a bug with the way a storybook's chapter number is calculated: It shows "Chapter 14/13" instead of "13/13".
Screen Shot 2020-11-10 at 1 35 32 PM

@Keerthi4308 Keerthi4308 self-assigned this Nov 10, 2020
@nya-elimu nya-elimu added the bug Something isn't working label Nov 10, 2020
@nya-elimu
Copy link
Member

This is what the database looks like for this storybook's chapters:

> SELECT * FROM StoryBookChapter WHERE storyBook_id = 66;
+-----+-----------+--------------+----------+
| id  | sortOrder | storyBook_id | image_id |
+-----+-----------+--------------+----------+
| 147 |         1 |           66 |      495 |
| 148 |         2 |           66 |      496 |
| 149 |         3 |           66 |      497 |
| 150 |         4 |           66 |      498 |
| 151 |         5 |           66 |      499 |
| 152 |         6 |           66 |      500 |
| 153 |         7 |           66 |      501 |
| 154 |         8 |           66 |      502 |
| 155 |         9 |           66 |      503 |
| 156 |        10 |           66 |      504 |
| 157 |        11 |           66 |      505 |
| 158 |        12 |           66 |      506 |
| 159 |        13 |           66 |      507 |
+-----+-----------+--------------+----------+
13 rows in set (0.00 sec)

The sortOrder is supposed to start at zero: https://github.com/elimu-ai/webapp/blob/master/src/main/java/ai/elimu/model/content/StoryBookChapter.java#L16

So something might have gone wrong when setting the sortOrder values during the import of the ePUB file.

@nya-elimu
Copy link
Member

The Hindi version of the same storybook does not have the same problem: http://hin.test.elimu.ai/content/storybook/edit/39

Screen Shot 2020-11-12 at 12 43 27 AM

🤔

@nya-elimu
Copy link
Member

nya-elimu commented Nov 11, 2020

@Keerthi4308
Copy link
Author

Interesting.. thanks for sharing them @nya-elimuai I'm taking a look now.

@nya-elimu
Copy link
Member

nya-elimu commented Nov 20, 2020

Note that the ePUB importer automatically removes storybook chapters that are not needed, i.e. book metadata: https://github.com/elimu-ai/webapp/blob/master/src/main/java/ai/elimu/web/content/storybook/StoryBookCreateFromEPubController.java#L364

if (isMetadata) {
    continue;
}

This might have a negative effect on how the sortOrder is set for each chapter.

@Keerthi4308
Copy link
Author

@nya-elimuai You are right the epub file for this storyBook has MetaData http://eng.elimu.ai/content/storybook/edit/66 which maps to Chapter with sortOrder = 0. As a result chapter with actual content has sortOrder 1 and we are adding sortOrder+1 while storing in DB. I observed that StoryBook start with Chapter 2/13 instead of 1/13 which leads to 14/13 with all the example storybooks you shared in the above comment sec.

Couple of options I can think of:

  1. Handle while we extract Pragrapgh from chapter itself based on if the paragraph contains metadata or not(Code ref) . That is either skip adding storeBookChapter altogether to storyBookChapters and it's corresponding pragraphs or manipulate the sortOrder for this chapter to be -1 and maintain a counter for other chapters sortOrder instead of storyBookChapter.setSortOrder(storyBookChapters.size());

  2. Maintain a counter for occurence of metaData and reset the sortOrder for every other StoryBookChapter just before storing in the DB as sortOrder- (occurence of metadata) . That is after this code logic.(Code ref).
    Ex: Chapter 0 has MetaData => metaDataCounter=1
    And for next Chapter 1 with sortOrder =1 => sortOrder= sortOrder- metaDataCounter => 0
    Chapter 2 has MetaData => metaDataCounter=2
    And for next Chapter 3 with sortOrder =3 => sortOrder= sortOrder- metaDataCounter => 1

I more leaned towards option 1 just that we can handle it upfront if we aren't using it anyway. Let me know your thoughts and whether you see any issues/concerns.

@Keerthi4308
Copy link
Author

Keerthi4308 commented Nov 29, 2020

Apart from that, I'm curious why are we receiving this sort of metaData only for some StoryBooks and not others because metadata info like author/illustrator/translator could infact be useful right, correct me if we are receiving this through some other means.

@nya-elimu
Copy link
Member

I more leaned towards option 1 just that we can handle it upfront if we aren't using it anyway. Let me know your thoughts and whether you see any issues/concerns.

@Keerthi4308 Thank you for tracking down the bug, and for suggesting how to solve it 👍

I have not looked at the details yet, so I'm not able to suggest the better of the two options. If you are leaning towards option 1, feel free to attempt an implementation of the bug. And let me know if I can assist.

@nya-elimu
Copy link
Member

nya-elimu commented Nov 30, 2020

Apart from that, I'm curious why are we receiving this sort of metaData only for some StoryBooks and not others because metadata info like author/illustrator/translator could infact be useful right, correct me if we are receiving this through some other means.

@Keerthi4308 Part of the challenge is that the ePUB files come from various sources, and they are all formatted differently. Currently we have a solution that works for 3 sources: StoryWeaver, Global Digital Library and Let's Read.

Every time a contributor imports an ePUB, she stores an attribution URL and the book's license so that we can keep track of this. Currently, this is done manually.

@nya-elimu nya-elimu self-assigned this Dec 3, 2020
nya-elimu added a commit that referenced this issue Dec 3, 2020
- Correct wrong sort order of storybook chapters
nya-elimu added a commit that referenced this issue Dec 3, 2020
…mber-displayed-incorrectly

fix: #1092 StoryBook chapter number displayed incorrectly
nya-elimu added a commit that referenced this issue Dec 3, 2020
nya-elimu added a commit that referenced this issue Dec 3, 2020
nya-elimu added a commit that referenced this issue Dec 3, 2020
…mber-displayed-incorrectly

Fix #1092 story book chapter number displayed incorrectly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants