Skip to content

Include only last published file when toc is published

Pokhi requested to merge fix/1149 into develop

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

  1. When the Update published version button is clicked, the publishToc resolver is called.
  2. The publishToc resolver executes command publishComponent for the toc https://gitlab.coko.foundation/ncbi/ncbi/-/blob/718676e9fefa910465dfd584a2cf77077d1b3df2/server/api/graphql/toc/toc.resolvers.js#L26
  3. 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
  4. 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
  5. The CreateTocXml listener is mapped to BookUpdated 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:

  1. Chapter 1 v1 - F1 (published)
  2. Chapter 2 v1 - F1 (published), F2 (new-upload)
  3. Chapter 1 v2 - F1 (published), F2 (previewing)

If the book's TOC is now published, it should include the following chapters with files:

  1. Chapter 1 - v2 - F1
  2. Chapter 2 - v1 - F1
Edited by Pokhi

Merge request reports