List comments and replied comments on a page

List comments and replied comments on a page

Scenario

When you have a page with a lengthy discussion or you want to keep track of the activity, you might want to get an overview of the discussion at a glance.

This report compiles and displays comments, commentators, and replied comments on a page inside a table.

Result

Recipe

Apps

Reporting for Confluence Data Center

Level

Intermediate

Estimated time

10 minutes

Macros

Local Reporter, Report Column, Report Info, Report Table

Suppliers

Body Supplier, Collection Supplier, Comment Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

<ac:structured-macro ac:macro-id="8b1610d6-aedb-455c-8aa4-10b724258ffc" ac:name="report-table" ac:schema-version="1"> <ac:rich-text-body> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="3ea68434-0d50-46eb-9ef4-f0a8830dd2a4" ac:name="local-reporter" ac:schema-version="1"> <ac:parameter ac:name="">page:all comments</ac:parameter> <ac:rich-text-body> <p> <br /> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="18e49fac-48d5-487a-a21e-60cfc975f56e" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Commentor</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="17e5f863-ce9f-4c38-95f7-c4e908864573" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">comment:creator</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="bc5888f5-ceea-439d-8e19-974222565bdf" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Comment</ac:parameter> <ac:rich-text-body> <p class="auto-cursor-target"> <ac:structured-macro ac:macro-id="53ca960c-f306-4cb5-9196-f27067ac3ad6" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">comment:summary</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="ab5d78c4-a1fc-43c5-a87f-a7d0407b940a" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Comments Repliers</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="dc1ba97b-adb4-48f1-b31f-9960783a09e3" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">comment:repliers</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p class="auto-cursor-target"> <br /> </p> <ac:structured-macro ac:macro-id="5e5aec9f-a1e9-46b7-90ca-d51beb406297" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="title">Replied Comments</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="2bf10fa0-088d-4420-b08d-4393c9260970" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="render">richtext</ac:parameter> <ac:parameter ac:name="">comment:children &gt; collect body &gt; collect text </ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> <p> <br /> </p> <ac:structured-macro ac:macro-id="9aa0177b-2f63-4392-8e88-2f7d978a01b8" ac:name="report-column" ac:schema-version="1"> <ac:parameter ac:name="injected">true</ac:parameter> <ac:parameter ac:name="title">Days ago</ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="d7a3d107-f2b3-44ef-bcc3-0eb096368ba1" ac:name="report-eval" ac:schema-version="1"> <ac:parameter ac:name="format">#</ac:parameter> <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter> <ac:plain-text-body><![CDATA[(%global:current date>date:milliseconds% - %comment:creation date>date:milliseconds%)/1000/60/60/24]]></ac:plain-text-body> </ac:structured-macro> <p> <br /> </p> </ac:rich-text-body> </ac:structured-macro> <p> <br /> </p> </ac:rich-text-body> </ac:structured-macro>

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a Report Table macro to host the report inside a table.

  2. Within the Report Table, because we want to report on a single page only, add a Local Reporter macro with Key set to page:all comments to get all comments on the page.

  3. Under the Local Reporter macro, create as many Report Column macros as you want to host the details of each macro. For example, create four Report Column macros with Title parameters set to Commentor, Comment, Comments Replier, and Replied Comments.

  4. Within each Report Column macro, add a Report Info macro with the corresponding Key parameter - comment:creator, comment:summary, comment:replies, and comment:children > collect body > collect text.

  5. Optionally, to calculate the time elapsed since the comment was made:

    1. Create another Report Column macro with the following parameters:

      • Title: Days ago

      • Injected: selected, because we are going to use an advanced notation.

    2. Within the Report Column macro, add a Report Evaluation macro with Format set to # so the number of days will be rounded.

    3. Within the Report Evaluation macro, add the following notation for the calculation:

      (%global:current date>date:milliseconds% - %comment:creation date>date:milliseconds%)/1000/60/60/24