AtlassianPS / ConfluencePS

Confluence REST API (including Cloud) via PowerShell
https://AtlassianPS.org/module/ConfluencePS
MIT License
149 stars 42 forks source link

-IncludeTotalCount not working #72

Open brianbunke opened 7 years ago

brianbunke commented 7 years ago

-IncludeTotalCount on the 2.0 Get-* commands seems to always return "Unknown total count" for me.

Expected Behavior

-IncludeTotalCount does something

Current Behavior

Regardless of whether PageSize is higher or lower than the actual total count of objects, I can't get any number to return. Instead, I always see "Unknown total count".

Possible Solution

I'd be fine if this parameter didn't exist. If you need to count, you can still (Get-ConfluenceSpace).Count. Happy to hear otherwise if I'm missing something, though.

Steps to Reproduce (for bugs)

Get-ConfluenceSpace -IncludeTotalCount
Get-ConfluencePage -SpaceKey TEST -IncludeTotalCount

Your Environment

ConfluencePS develop branch, future v2.0

lipkau commented 7 years ago

This parameter is auto-generated with

[CmdletBinding(SupportsPaging = $true)]

The TotalCount is defined in this line:

$PSCmdlet.PagingParameters.NewTotalCount($response.size, $Accuracy)

source

$accuracy is a float between 1 and 0. 1 means the number is 100% accurate 0 means the number is 0% accurate As we don't get any indication of the REST how many results will be returned, 0 was the most appropriated at the time.

However

We can count the results per page and send it along with the self-invocation in order to know how many results were returned. And only display the Total count at the end of the result set.

Would that be ok for you?

brianbunke commented 7 years ago

...I did not realize SupportsPaging auto-generated parameters.

I like that suggestion. As a user, I don't expect count to come before the results anyway.

lipkau commented 7 years ago

How to implement this