Skip to content

Commit

Permalink
add some comments and docs to the paging object
Browse files Browse the repository at this point in the history
  • Loading branch information
endyApina committed Jul 22, 2024
1 parent ca908d9 commit a921bd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkg/query/paging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ func ValidateAndApplyPagingRules(model PagingSettingsInterface, request *Request
ValidateAndApplyPagingRules performs a validation of the original request and adds correct the correct values \(defaults\) if needed

<a name="Response"></a>
## type [Response](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/query/paging/response.go#L6-L11>)
## type [Response](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/query/paging/response.go#L8-L13>)

Response represents a response object containing information about pagination and total count of records.

- PageIndex: The index of the page \(starting from 0\).
- PageSize: The number of records per page.
- PageIndex: The index of the page \(starting from 0\). This is required.
- PageSize: The number of records per page. This is required.
- TotalDisplayableResults: The total number of results that can be displayed. This is required.
- TotalResults: The total number of results, including those that may not be displayed. This is optional and will be omitted if empty.

```go
type Response struct {
Expand All @@ -118,7 +120,7 @@ type Response struct {
```

<a name="NewResponse"></a>
### func [NewResponse](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/query/paging/response.go#L13>)
### func [NewResponse](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/query/paging/response.go#L15>)

```go
func NewResponse(request *Request, totalDisplayableResults, totalResults uint64) *Response
Expand Down
6 changes: 4 additions & 2 deletions pkg/query/paging/response.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package paging

// Response represents a response object containing information about pagination and total count of records.
// - PageIndex: The index of the page (starting from 0).
// - PageSize: The number of records per page.
// - PageIndex: The index of the page (starting from 0). This is required.
// - PageSize: The number of records per page. This is required.
// - TotalDisplayableResults: The total number of results that can be displayed. This is required.
// - TotalResults: The total number of results, including those that may not be displayed. This is optional and will be omitted if empty.
type Response struct {
PageIndex int `json:"index" binding:"required"`
PageSize int `json:"size" binding:"required"`
Expand Down

0 comments on commit a921bd5

Please sign in to comment.