Skip to content

Conversation

@lpoli
Copy link
Contributor

@lpoli lpoli commented Jul 19, 2022

Changes

Add GetRecentlyAddedRefs function to solve issue #702

Tests

Tasks to complete before merging PR:

  • Ensure system tests are passing. If not Run them manually to check for any regressions 📋
  • Do any new system tests need added to test this change? do any existing system tests need updated? If so create a PR at 0chain/system_test
  • Merge your system tests PR to master AFTER merging this PR

Associated PRs (Link as appropriate):

  • 0chain:
  • gosdk:
  • system_test:
  • zboxcli:
  • zwalletcli:
  • Other: ...
@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2022

Codecov Report

Merging #755 (4918c37) into staging (89c9544) will decrease coverage by 0.25%.
The diff coverage is 3.22%.

@@ Coverage Diff @@ ## staging #755 +/- ## =========================================== - Coverage 24.65% 24.40% -0.26%  =========================================== Files 77 77 Lines 7872 7958 +86 =========================================== + Hits 1941 1942 +1  - Misses 5663 5748 +85  Partials 268 268 
Flag Coverage Δ
Unit-Tests 24.40% <3.22%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../0chain.net/blobbercore/allocation/newdirchange.go 0.00% <0.00%> (ø)
.../0chain.net/blobbercore/handler/storage_handler.go 23.28% <0.00%> (-1.93%) ⬇️
code/go/0chain.net/blobbercore/reference/ref.go 0.00% <ø> (ø)
.../0chain.net/blobbercore/reference/referencepath.go 0.00% <0.00%> (ø)
code/go/0chain.net/blobbercore/handler/handler.go 56.49% <12.50%> (-0.87%) ⬇️
...chain.net/blobbercore/allocation/copyfilechange.go 56.77% <100.00%> (ø)
....net/blobbercore/allocation/file_changer_upload.go 50.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

r.HandleFunc("/v1/file/referencepath/{allocation}", common.ToJSONResponse(WithReadOnlyConnection(ReferencePathHandler)))
r.HandleFunc("/v1/file/objecttree/{allocation}", common.ToStatusCode(WithStatusReadOnlyConnection(ObjectTreeHandler))).Methods(http.MethodGet, http.MethodOptions)
r.HandleFunc("/v1/file/refs/{allocation}", common.ToJSONResponse(WithReadOnlyConnection(RefsHandler))).Methods(http.MethodGet, http.MethodOptions)
r.HandleFunc("/v1/file/recent-refs/{allocation}", common.ToJSONResponse(WithReadOnlyConnection(RecentRefsRequestHandler))).Methods(http.MethodGet, http.MethodOptions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URI would be more consistent if it is /v1/file/refs/recent/{allocation}

return nil, common.NewError("invalid_parameters", "Zero/Negative page limit value is not allowed")
}

if pageLimit > PageLimit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename the global PageLimit to MaxPageLimit

}

} else {
pageLimit = PageLimit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And have a DefaultPageLimit if no pageLimit is set, it could be 20 for example, we'd better not return max limit if no limit is specified.

// creation date for "/a", "/a/b", "/a/b/c", "/a/b/c/d", "/a/b/c/d/e" and "/a/b/c/d/e/f.txt" will be the same.
// The refs returned will be in "/a/b/c/d/e/f.txt", "/a/b/c/d/e", ... order.
//
// pageLimit --> maximum number of refs to returs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo returs

var count int64
go func() {
errCh <- db.Model(&Ref{}).Where("allocation_id=? AND created_at > ?",
allocID, fromDate).Count(&count).Error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to return the total pages as it would require us to query total items count everytime, which then would cause performance issue. Users can send requests with offset and limit till the returned items count < limit.

@service-0chain
Copy link
Collaborator

Manual system tests [failure] with the following config

config value
tests skipped FALSE
system-tests feature/recent-refs
gosdk feature/list-recent-files
zboxcli feature/list-recent-files
zwalletcli staging
0chain staging
blobber feature/list-recent-files
authorizer staging
0box staging
0block staging
0dns staging
explorer staging
0proxy staging
0search staging
@service-0chain
Copy link
Collaborator

Manual system tests [success] with the following config

config value
tests skipped FALSE
system-tests feature/recent-refs
gosdk feature/list-recent-files
zboxcli feature/list-recent-files
zwalletcli staging
0chain staging
blobber feature/list-recent-files
authorizer staging
0box staging
0block staging
0dns staging
explorer staging
0proxy staging
0search staging
Copy link
Contributor

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lpoli lpoli merged commit 3c0de5f into staging Aug 10, 2022
@lpoli lpoli deleted the feature/list-recent-files branch August 10, 2022 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants