-
Notifications
You must be signed in to change notification settings - Fork 221
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
Support name filter at get workflows #1525
Support name filter at get workflows #1525
Conversation
for `getLatestActiveWorkflowDefinitions`
siteId, | ||
pageSize, | ||
lastId.or(0L), | ||
name.isPresent() && !name.get().isEmpty() ? "%" + escapeLikeParameter(name.get()) + "%" : "%", |
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.
If name
parameter is absent
, this method just sets %
so that the name filter does not affect.
siteId, | ||
pageSize, | ||
lastId.or(0L), | ||
name.isPresent() && !name.get().isEmpty() ? "%" + escapeLikeParameter(name.get()) + "%" : "%", |
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.
I felt it was difficult to understand what this line is trying. How about adding a comment on this line or extracting this line to a private method like createWorkflowNamePattern()
or something?
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.
I will add a comment to explain the intention the index structure on workflow_definition
, and the performance insight on the SQL statement of dao. getLatestActiveWorkflowDefinitions
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.
Can you put the SQL query you used to get the query plan? I'm interested in whether current index works with suffix/partial match. |
" and <acFilter>" + | ||
" order by wd.id" + | ||
" limit :limit") | ||
List<StoredWorkflowDefinitionWithProject> getLatestActiveWorkflowDefinitions( | ||
@Bind("siteId") int siteId, | ||
@Bind("limit") int limit, | ||
@Bind("lastId") long lastId, | ||
@Bind("name") String name, |
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.
namePattern
or something is more correct?
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.
renamed at 601788e
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.
Hmm... I can't see the change on this code review....
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.
Sorry. Now I fixed at 102cb3a
@@ -625,6 +639,7 @@ public void deleteSchedules(int projId) | |||
@Bind("siteId") int siteId, | |||
@Bind("limit") int limit, | |||
@Bind("lastId") long lastId, | |||
@Bind("name") String name, |
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.
Same as above
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.
renamed at 601788e
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.
Sorry. Now I fixed at 102cb3a
@QueryParam("count") Integer count) | ||
@QueryParam("count") Integer count, | ||
@ApiParam(value="name pattern to be partially matched", required=false) | ||
@QueryParam("name") String name |
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.
Same as above?
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.
renamed at 601788e
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.
Sorry. Now I fixed at 102cb3a
to describe the performance of like search
@komamitsu |
@@ -355,6 +360,19 @@ public TimeZoneMap getWorkflowTimeZonesByIdList(List<Long> defIdList) | |||
Map<Long, ZoneId> map = IdTimeZone.listToMap(list); | |||
return new TimeZoneMap(map); | |||
} | |||
|
|||
private String generatePartialMatchPattern(Optional<String> pattern) |
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.
👍
{ | ||
// If provided pattern is absent or empty string, just set '%' | ||
// so that the pattern does not affect to a where clause. | ||
return pattern.isPresent() && !pattern.get().isEmpty() ? "%" + escapeLikePattern(pattern.get()) + "%" : "%"; |
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.
pattern.or("").isEmpty()
is simpler?
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.
fixed at 3ea375a
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.
👍
Thanks! |
…kflows Support name filter at get workflows
What does this PR change?
This PR introduces
name
parameter intoGET /api/workflows
endpoint so that users can filter workflows by name partial match.I confirmed that this updates does not change the SQL statement execution plan at PostgreSQL by
explain
command.Comparison of SQL statement execution plan
Currently
workflow_definitions_on_revision_id_and_name
index onworkflow_definitions
table is already used.After modification of this PR, same index is used.