Try this macro
## Macro title: Space Meta Data 2 ## Macro has a body: Y or N (N) ## Body processing: Selected body processing option ## Output: Selected output option ## ## Developed by: Matthew Horn, based on Space Meta Data by Andrew Frayling ## Date created: 06/07/2012 ## Installed by: <your name> ## Macro to display information such as number of pages, number of blog posts, attachment size, etc. about a named Space. ## @param TargetSpace:title=Target space|type=string|desc=Enter the KEY of the space you want metadata for. For example, coredoc, gscontent, samples, wncontent|required=true|multiple=false ## Get space details #set ( $targetSpace = $spaceManager.getSpace($paramTargetSpace) ) #set ( $spaceName = $targetSpace.getName() ) #set ( $spaceKey = $targetSpace.getKey() ) #set ( $spaceHome = $targetSpace.getHomePage() ) #set ( $spaceCreator = $targetSpace.getCreatorName() ) #set ( $spaceCreationDate = $targetSpace.getCreationDate() ) #set ( $spaceDescription = $targetSpace.getDescription() ) #set ( $pageCount = $spaceManager.findPageTotal($targetSpace) ) #set ( $blogCount = $spaceManager.getNumberOfBlogPosts($targetSpace) ) ## Get all pages in the current Space #set ( $allPagesInSpace = $pageManager.getPages($targetSpace, true) ) ## Reset total attachment file size #set ( $totalAttachmentFileSizeForSpace = 0 ) ## Reset total number of attachments #set ( $totalAttachmentCount = 0 ) ## Loop through all pages in the current Space #foreach ($page in $allPagesInSpace) ## reset the attachment count for each page #set ( $pageAttachmentCount = 0 ) ## reset the attachment file size total for each page #set ( $totalFileSizePerPage = 0 ) ## get the attachments for each page #set ( $allAttachments = $page.getAttachments() ) ## Loop through each attachment #foreach ($attachment in $allAttachments) ## Increment the attachment count for the page #set ( $pageAttachmentCount = $pageAttachmentCount + 1 ) ## Sum the size of the attachments on the page #set ( $totalFileSizePerPage = $totalFileSizePerPage + $attachment.getFileSize() ) #end ## End looping through attachments ## Increment total attachment count for the current Space #set ( $totalAttachmentCount = $totalAttachmentCount + $pageAttachmentCount ) ## Sum the total size of attachments for the current Space #set ( $totalAttachmentFileSizeForSpace = $totalAttachmentFileSizeForSpace + $totalFileSizePerPage ) #end ## End looping through pages ## Convert attachment size to MBs #set ( $attachmentSizeMb = ($totalAttachmentFileSizeForSpace / 1024.00) / 1024.00 ) ## Display Space Details <table class="confluenceTable"> <tbody> <tr> <th class="confluenceTh">Name</th> <td class="confluenceTd">$spaceName</td> </tr> <tr> <th class="confluenceTh">Key</th> <td class="confluenceTd">$spaceKey</td> </tr> <tr> <th class="confluenceTh">Description</th> <td class="confluenceTd">$spaceDescription.getBodyAsString()</td> </tr> <tr> <th class="confluenceTh">Home Page</th> <td class="confluenceTd">#contentLink2($spaceHome true false)</td> </tr> <tr> <th class="confluenceTh">Created By</th> <td class="confluenceTd">#usernameLink($spaceCreator) ($action.dateFormatter.formatDateTime($spaceCreationDate))</td> </tr> <tr> <th class="confluenceTh">Number of Pages</th> <td class="confluenceTd">$pageCount</td> </tr> <tr> <th class="confluenceTh">Number of Blog Posts</th> <td class="confluenceTd">$blogCount</td> </tr> <tr> <th class="confluenceTh">Number of Attachments</th> <td class="confluenceTd">$totalAttachmentCount (including all versions)</td> </tr> <tr> <th class="confluenceTh">Total Size of Attachments</th> <td class="confluenceTd">$attachmentSizeMb MB</td> </tr> </tbody> </table>
Not really. First, you need to define what size you're looking for? Raw-uncompressed text (as in characters on a page) should be possible, but that won't take account of macros that do things like "show one page in another". Or actually what's presented to the user? Or the size of what's stored in the database? etc.
It might be better to explain why you are asking this question - what use is the statistic to you?
Good Question Nic,
We have spaces categorized under Business Unit and every business unit has a business head. We would like to show how much work has been done under which business unit. The intent is also to ask teams that are lagging behind to speed up their documentation process.
I do have a macro which publishes total number of pages and number of blank pages in a space but that does not give a good picture as many pages have 1-2 lines of text ad few parent pages have children display macro.
I would like to present factual data that this much MB of data has been created under these business units since inception of Confluence.
I am fine with raw character size or size of space in DB. It should help me portray the progress till date.
I like the idea of a macro to publish the raw data, but I don't think there's one that does "word count for a range of pages". If a user macro could be written to do that, I think it would solve the problem (for this case, word count is more useful than number of pages, I think)
I think you might have to resort to the database, but I'm not sure it'll be easy. BodyContent is the table you'll want as the core of the query, but that doesn't directly contain which space a page is in, so you'll need to read a bit more to establish that. Then, I don't know who to find out how much space a specific row in a table takes up.
So, I'm really sorry, I don't have a good answer for this one, just some vague thoughts about how to approach it. I did look for a "word count" add on or macro, but couldn't find one!
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs