Targets: #1149
Changes proposed
-
Create a new table published_file_versions
-
When a chapter (book_component) status changes to published
, insert a row into the table containing the details of the book metadata and book component metadata -
When building book TOC, read metadata of the latest published file of each chapter that was once published
Flow of updating published version of book TOC
- When the
Update published version
button is clicked, thepublishToc
resolver is called. - The
publishToc
resolver executes commandpublishComponent
for the toc https://gitlab.coko.foundation/ncbi/ncbi/-/blob/718676e9fefa910465dfd584a2cf77077d1b3df2/server/api/graphql/toc/toc.resolvers.js#L26 - When the toc
publishComponent
command is running, at one point the domain update command is executed https://gitlab.coko.foundation/ncbi/ncbi/-/blob/718676e9fefa910465dfd584a2cf77077d1b3df2/server/services/CommandService/tocCommands/commands/publishComponent.js#L138 - After the book has been successfully update, the
BookUpdated
event is fired https://gitlab.coko.foundation/ncbi/ncbi/-/blob/718676e9fefa910465dfd584a2cf77077d1b3df2/server/services/CommandService/domainCommands/commands/updateCommand.js#L135 - The
CreateTocXml
listener is mapped toBookUpdated
event and hence it get called. https://gitlab.coko.foundation/ncbi/ncbi/-/blob/718676e9fefa910465dfd584a2cf77077d1b3df2/config/default.js#L68
Consider a book with the following chapters and converted files:
- Chapter 1 v1 - F1 (published)
- Chapter 2 v1 - F1 (published), F2 (new-upload)
- Chapter 1 v2 - F1 (published), F2 (previewing)
If the book's TOC is now published, it should include the following chapters with files:
- Chapter 1 - v2 - F1
- Chapter 2 - v1 - F1