Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jun 3, 2015
1 parent 3e0ec6e commit dedd1e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes.md
Expand Up @@ -56,6 +56,8 @@ This is dependent on database size and the system administrator should consider
* [1147304](https://bugzilla.redhat.com/show_bug.cgi?id=1147304) - Project search fails on special characters
* [1123186](https://bugzilla.redhat.com/show_bug.cgi?id=1123186) - Project search fails for multiple word project names
* [1112498](https://bugzilla.redhat.com/show_bug.cgi?id=1112498) - Unable to remove self as maintainer
* [1227575](https://bugzilla.redhat.com/show_bug.cgi?id=1227575) - Exception on emptying the search field when many users were reported

-----------------------

<h5>New Features</h5>
Expand Down
16 changes: 9 additions & 7 deletions zanata-war/src/main/java/org/zanata/action/ProjectSearch.java
Expand Up @@ -45,9 +45,12 @@ public class ProjectSearch implements Serializable {
private QueryProjectPagedListDataModel queryProjectPagedListDataModel =
new QueryProjectPagedListDataModel(DEFAULT_PAGE_SIZE);

// Count of result to be return as part of autocomplete
// Count of project to be return as part of autocomplete
private final static int INITIAL_RESULT_COUNT = 10;

// Count of person to be return as part of autocomplete
private final static int INITIAL_PERSON_RESULT_COUNT = 20;

public DataModel getProjectPagedListDataModel() {
return queryProjectPagedListDataModel;
}
Expand Down Expand Up @@ -91,16 +94,15 @@ public List<SearchResult> suggest() {
String searchQuery = getQuery().trim();
boolean includeObsolete = false;
List<HProject> searchResult =
projectDAO.searchProjects(
searchQuery,
INITIAL_RESULT_COUNT,
0,
includeObsolete);
projectDAO.searchProjects(searchQuery,
INITIAL_RESULT_COUNT, 0, includeObsolete);

for (HProject project : searchResult) {
result.add(new SearchResult(project, null));
}
List<HAccount> hAccounts = accountDAO.searchQuery(searchQuery);
List<HAccount> hAccounts =
accountDAO.searchQuery(searchQuery,
INITIAL_PERSON_RESULT_COUNT, 0);
for (HAccount hAccount : hAccounts) {
result.add(new SearchResult(null, hAccount));
}
Expand Down
4 changes: 3 additions & 1 deletion zanata-war/src/main/java/org/zanata/dao/AccountDAO.java
Expand Up @@ -132,12 +132,14 @@ public HAccount create(String username, String password, boolean enabled) {
@SuppressWarnings("unchecked")
// TODO: use hibernate search
public
List<HAccount> searchQuery(String searchQuery) {
List<HAccount> searchQuery(String searchQuery, int maxResults, int firstResult) {
String userName = "%" + searchQuery + "%";
Query query =
getSession().createQuery(
"from HAccount as a where lower(a.username) like lower(:username)");
query.setParameter("username", userName);
query.setMaxResults(maxResults);
query.setFirstResult(firstResult);
query.setComment("AccountDAO.searchQuery/username");
return query.list();
}
Expand Down

0 comments on commit dedd1e9

Please sign in to comment.