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 Server & Data Center

Apps

Reporting for Confluence Server & 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. Add a Local Reporter macro inside the report-table macro, because we are interested to report on a single page only. To get all comments on the page, make sure key is set to "page:all comments".

  3. Now, create as many report-column macros with report-info macros as you wish. These would host all the details of each comment. To retrieve details of the comments, we can make use of the keys available through Comment Supplier.

    In this example, we create these columns with corresponding key for report-info macros:

    1. The user who commented, with key "comment:creator"

    2. The comment summary, with key "comment:summary"

    3. The user(s) who replied to the comment, with key "comment:repliers"

    4. The comment summary, with key "comment:children > collect body > collect text ". This retrieves the replies and displays the comment replies.

  4. (Bonus) To calculate the time lapsed since the comment was made, create another report-column macro called "Days ago". Enable injection, because we are going to use an advanced notation. Create a report-eval macro and set format to "#" so the number of days will be rounded. To calculate, use this notation for the report-eval macro: 

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

    Â