Skip to content

Commit 19597ed

Browse files
committed
refactor: #9 Improve confluence space search algorithm to return results when no space is found by key.
1 parent 3c766f5 commit 19597ed

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

plugins/confluence/src/main/java/com/github/vogoltsov/vp/plugins/confluence/client/ConfluenceSpaceRepository.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import com.github.vogoltsov.vp.plugins.confluence.util.cql.CQL;
1010
import com.github.vogoltsov.vp.plugins.confluence.util.cql.CQLQuery;
1111

12+
import java.util.Collections;
1213
import java.util.Objects;
14+
import java.util.Optional;
15+
import java.util.stream.Collectors;
1316

1417
/**
1518
* @author Vitaly Ogoltsov <vitaly.ogoltsov@me.com>
@@ -25,14 +28,17 @@ public static ConfluenceSpaceRepository getInstance() {
2528
* Searches all spaces by title and key.
2629
*/
2730
public DataPage<Space> search(String text) {
31+
Space space = findByKey(text);
32+
if (space != null) {
33+
return DataPage.of(Collections.singletonList(space));
34+
}
2835
CQLQuery cql = CQL.query(
2936
CQL.eq("type", "space")
3037
);
3138
if (text != null && !text.isEmpty()) {
3239
cql.and(CQL.or(
3340
CQL.like("space", text),
34-
CQL.like("space", text + "*"),
35-
CQL.eq("space.key", text)
41+
CQL.like("space", text + "*")
3642
));
3743
}
3844
cql.orderBy("title");

plugins/confluence/src/main/java/com/github/vogoltsov/vp/plugins/confluence/dialog/ConfluenceSpaceChooserDialog.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ protected String getTitle() {
2424
protected HelpPanel createHelpPanel() {
2525
return new HelpPanel(
2626
"",
27-
"Confluence spaces are created on a per-project basis." +
28-
" Search by space key or name."
27+
"<html><body>" +
28+
"<p>" +
29+
"Confluence spaces are created on a per-project basis." +
30+
"</p>" +
31+
"<p>" +
32+
"Searches confluence spaces by key (only exact match is returned) or by name (using fuzzy search)," +
33+
" if no space if found by key." +
34+
"</p>"
2935
);
3036
}
3137

0 commit comments

Comments
 (0)