-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/list recent files #755
Conversation
…bber into fix/update-attributes
Remove deleted_at column Update tests Optimize *change.go files
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -61,6 +61,7 @@ func SetupHandlers(r *mux.Router) { | |||
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Manual system tests [failure] with the following config
|
Manual system tests [success] with the following config
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Changes
Add
GetRecentlyAddedRefs
function to solve issue #702Tests
Tasks to complete before merging PR:
Associated PRs (Link as appropriate):