User setting to sort comments #2307

Open
andileni wants to merge 3 commits from andileni/vikunja:main into main
First-time contributor

Following the discussion here https://community.vikunja.io/t/add-option-to-sort-comments/2286/8 this implements the needed functionality.
I tested it on my end as good as I could, but no guarantee.
Please have a look and point out any issues which must be fixed before merging.

Thanks and kind regards
Andreas

Following the discussion here https://community.vikunja.io/t/add-option-to-sort-comments/2286/8 this implements the needed functionality. I tested it on my end as good as I could, but no guarantee. Please have a look and point out any issues which must be fixed before merging. Thanks and kind regards Andreas
andileni added 3 commits 2024-04-27 12:03:38 +00:00
konrad requested changes 2024-05-05 13:46:12 +00:00
konrad left a comment
Owner

Please also check why the CI fails and make it pass.

Please also check why the CI fails and make it pass.
@ -38,2 +39,4 @@
TaskID int64 `xorm:"not null" json:"-" param:"task"`
// The query parameter to order the items by. This can be either asc or desc, with asc being the default.
OrderBy []string `query:"order_by" json:"order_by"`
Owner

There should be a SortBy as well for the property to sort comments by. "Order asc / desc" does not tell you which property the sorting is using. Similar to how sorting is done in the TaskCollection.

No need to implement any other property than created in this PR but it should be extendable without breaking changes in the future.

Please exclude this from json as it's not used in the actual comment and document this as query parameter in the swagger annotation comment.

There should be a `SortBy` as well for the property to sort comments by. "Order asc / desc" does not tell you which property the sorting is using. Similar to how sorting is done in the `TaskCollection`. No need to implement any other property than `created` in this PR but it should be extendable without breaking changes in the future. Please exclude this from `json` as it's not used in the actual comment and document this as query parameter in the swagger annotation comment.
@ -271,3 +275,3 @@
Where(builder.And(where...)).
Join("LEFT", "users", "users.id = task_comments.author_id").
OrderBy("task_comments.created asc")
OrderBy(fmt.Sprintf("task_comments.created %s", tc.OrderBy[0]))
Owner

Please use "task_comments.created " + orderBy and make sure the property to order is defined. With this approach, the api will crash when you do not pass an order parameter.

Please use `"task_comments.created " + orderBy` and make sure the property to order is defined. With this approach, the api will crash when you do not pass an order parameter.
Some checks failed
continuous-integration/drone/pr Build is failing
Required
Details
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#2307
No description provided.