Open
Conversation
qiarie
requested changes
Dec 8, 2022
Comment on lines
+84
to
+93
| String strval = jsonObject.optString(filter); | ||
| if (strval.equals("")) { | ||
| return null; | ||
| } | ||
| if (!strval.contains(":")) { | ||
| return new DateTime[]{new DateTime(strval), new DateTime(strval)}; | ||
| } | ||
| DateTime d1 = new DateTime(strval.substring(0, strval.indexOf(":"))); | ||
| DateTime d2 = new DateTime(strval.substring(strval.indexOf(":") + 1)); | ||
| return new DateTime[]{d1, d2}; |
Contributor
There was a problem hiding this comment.
Should we handle cases of an invalid format for strval?
Comment on lines
+264
to
+279
| public static Integer setCoreFilters(JSONObject jsonObject, ClientSearchBean searchBean) throws ParseException { | ||
|
|
||
| Integer limit = !jsonObject.optString("limit").equals("") ? Integer.parseInt(jsonObject.optString("limit")) | ||
| : jsonObject.optInt("limit"); | ||
| if (limit == 0) { | ||
| limit = 100; | ||
| } | ||
|
|
||
| DateTime[] lastEdit = RestUtils.getDateRangeFilter(LAST_UPDATE, jsonObject);//TODO client by provider id | ||
| if (lastEdit != null) { | ||
| searchBean.setLastEditFrom(lastEdit[0]); | ||
| searchBean.setLastEditTo(lastEdit[1]); | ||
| } | ||
|
|
||
| return limit; | ||
| } |
Contributor
There was a problem hiding this comment.
Deduplicate common code in the 2 methods named setCoreFilters
qiarie
reviewed
Jan 17, 2023
| } | ||
|
|
||
| public static DateTime[] getDateRangeFilter(String filter, Object object) throws ParseException { | ||
| String strval; |
qiarie
reviewed
Mar 7, 2023
| } | ||
| } | ||
| catch (IllegalArgumentException e) { | ||
| e.printStackTrace(); |
Contributor
There was a problem hiding this comment.
Let's use the logger for this error
qiarie
reviewed
Mar 7, 2023
| throw new RuntimeException("A required field " + p + " was not found in resource class"); | ||
| } | ||
| catch (IllegalAccessException e) { | ||
| e.printStackTrace(); |
qiarie
reviewed
Mar 7, 2023
| @@ -92,48 +106,50 @@ public static boolean getBooleanFilter(String filter, HttpServletRequest req) { | |||
| public static void main(String[] args) { | |||
| System.out.println(new DateTime("1458932400000")); | |||
Contributor
There was a problem hiding this comment.
Unrelated to this update, but should we still have this?
Contributor
Author
There was a problem hiding this comment.
I am not sure. The code works without that main method
qiarie
reviewed
Mar 7, 2023
| DateTime d2 = Utils.getDateTimeFromString(strval.substring(strval.indexOf(":") + 1)); | ||
| return new DateTime[] { d1, d2 }; | ||
| } else { | ||
| return null; |
Contributor
There was a problem hiding this comment.
Where the call happens, what are the implications of returning a null date?
Contributor
Author
There was a problem hiding this comment.
There is a null check for the date fields e.g
…p/opensrp-server-web into 1172-master-allow-search-via-post
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
addresses issue #1173 for master branch