Skip to content
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

Fix Activity Limit #10165

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-activity-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix activity limit

When requesting a limit on activities, ocis would limit first, then filter and sort. Now it filters and sorts first, then limits.

https://github.com/owncloud/ocis/pull/10165
8 changes: 4 additions & 4 deletions services/activitylog/pkg/service/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h
for _, e := range evRes.GetEvents() {
delete(toDelete, e.GetId())

if limit != 0 && len(resp.Activities) >= limit {
continue
}

if !activityAccepted(e) {
continue
}
Expand Down Expand Up @@ -221,6 +217,10 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h

sort(resp.Activities)

if limit > 0 && limit < len(resp.Activities) {
resp.Activities = resp.Activities[:limit]
}

b, err := json.Marshal(resp)
if err != nil {
s.log.Error().Err(err).Msg("error marshalling activities")
Expand Down