-
Notifications
You must be signed in to change notification settings - Fork 68
feat: Initial support for multi-sort #335
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
Merged
andrii-bodnar
merged 9 commits into
crowdin:master
from
korzol:feature/235-add-orderBy-param-to-list-methods
Oct 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c7c3e8c
wip: Initial support for multi-sort
korzol c8cb503
wip: Keep field and sort direction in pojo class. Use List instead of…
korzol 0701742
wip: add orderBy support to list user tasks and projects
korzol 02dd81c
wip: Slight improvements in listProjects test
korzol d00ce51
wip: second part of orderBy implementation in list methods. List proj…
korzol 55031a1
wip: third part of orderBy implementation in list methods
korzol 23d2923
wip: fourth part of orderBy implementation in list methods
korzol 56279ac
wip: fifth part of orderBy implementation in list methods
korzol c334cd2
docs: add example for sorting list* results
korzol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/java/com/crowdin/client/core/http/impl/util/RequestEncoder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.crowdin.client.core.http.impl.util; | ||
|
|
||
| import java.io.UnsupportedEncodingException; | ||
| import java.net.URLEncoder; | ||
|
|
||
| public class RequestEncoder { | ||
| public static String encodeSpaces(String url) { | ||
| try { | ||
| return URLEncoder.encode(url, "UTF-8").replaceAll("\\+", "%20"); | ||
| } catch (UnsupportedEncodingException e) { | ||
| return null; | ||
| } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.crowdin.client.core.http.impl.util; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import com.crowdin.client.core.model.SortOrder; | ||
|
|
||
| public class SortOrderGenerator { | ||
| public static String generateSortParam(Map<String, SortOrder> orderByMap) { | ||
| if (orderByMap == null || orderByMap.isEmpty()) { | ||
| return null; | ||
| } | ||
|
|
||
| String sortParam = orderByMap.entrySet().stream() | ||
| .map(entry -> { | ||
| if (entry.getValue() == null) { | ||
| entry.setValue(SortOrder.ASC); | ||
| } | ||
|
|
||
| return entry.getKey() + " " + entry.getValue().to(entry.getValue()); | ||
| }) | ||
| .collect(Collectors.joining(",")); | ||
|
|
||
| return RequestEncoder.encodeSpaces(sortParam); | ||
|
|
||
|
|
||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/crowdin/client/core/model/SortOrder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.crowdin.client.core.model; | ||
|
|
||
| public enum SortOrder implements EnumConverter<SortOrder> { | ||
| ASC, DESC; | ||
|
|
||
| public static SortOrder from(String value) { | ||
| if (value == null) return ASC; | ||
|
|
||
| return SortOrder.valueOf(value.toUpperCase()); | ||
| } | ||
|
|
||
| @Override | ||
| public String to(SortOrder v) { | ||
| return (v != null ? v : ASC).name().toLowerCase(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "data": { | ||
| "id": 1, | ||
| "projectId": 12, | ||
| "creatorId": 6, | ||
| "type": 1, | ||
| "status": "todo", | ||
| "title": "French#1", | ||
| "assignees": [ | ||
| { | ||
| "id": 1, | ||
| "username": "john_smith", | ||
| "fullName": "john_smith", | ||
| "avatarUrl": "", | ||
| "wordsCount": 5, | ||
| "wordsLeft": 3 | ||
| } | ||
| ], | ||
| "assignedTeams": [ | ||
| { | ||
| "id": 1, | ||
| "wordsCount": 5 | ||
| } | ||
| ], | ||
| "fileIds": [ | ||
| 1 | ||
| ], | ||
| "progress": { | ||
| "total": 24, | ||
| "done": 15, | ||
| "percent": 62 | ||
| }, | ||
| "sourceLanguageId": "en", | ||
| "targetLanguageId": "fr", | ||
| "description": "Proofread all French strings", | ||
| "hash": "dac37aff364d83899128e68afe0de4994", | ||
| "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", | ||
| "wordsCount": 24, | ||
| "filesCount": 2, | ||
| "commentsCount": 0, | ||
| "deadline": "2019-09-27T07:00:14+00:00", | ||
| "timeRange": "string", | ||
| "workflowStepId": 10, | ||
| "createdAt": "2019-09-23T09:04:29+00:00", | ||
| "updatedAt": "2019-09-23T09:04:29+00:00" | ||
| } | ||
| }, | ||
| { | ||
| "data": { | ||
| "id": 2, | ||
| "projectId": 12, | ||
| "creatorId": 6, | ||
| "type": 1, | ||
| "status": "todo", | ||
| "title": "French#2", | ||
| "assignees": [ | ||
| { | ||
| "id": 1, | ||
| "username": "john_smith", | ||
| "fullName": "john_smith", | ||
| "avatarUrl": "", | ||
| "wordsCount": 5, | ||
| "wordsLeft": 3 | ||
| } | ||
| ], | ||
| "assignedTeams": [ | ||
| { | ||
| "id": 1, | ||
| "wordsCount": 5 | ||
| } | ||
| ], | ||
| "fileIds": [ | ||
| 1 | ||
| ], | ||
| "progress": { | ||
| "total": 24, | ||
| "done": 15, | ||
| "percent": 62 | ||
| }, | ||
| "sourceLanguageId": "en", | ||
| "targetLanguageId": "fr", | ||
| "description": "Proofread all French strings", | ||
| "hash": "dac37aff364d83899128e68afe0de4994", | ||
| "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", | ||
| "wordsCount": 24, | ||
| "filesCount": 2, | ||
| "commentsCount": 0, | ||
| "deadline": "2019-09-27T07:00:14+00:00", | ||
| "timeRange": "string", | ||
| "workflowStepId": 10, | ||
| "createdAt": "2019-09-23T09:04:29+00:00", | ||
| "updatedAt": "2019-09-23T09:04:29+00:00" | ||
| } | ||
| } | ||
| ], | ||
| "pagination": { | ||
| "offset": 0, | ||
| "limit": 25 | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.