mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Limit item search results
Add a limit on item search results so the user is not overwhelmed.
This commit is contained in:
parent
c6b5e28755
commit
45c7ac15bd
@ -7,26 +7,24 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ItemSearcher implements CallHandler {
|
public class ItemSearcher implements CallHandler {
|
||||||
|
|
||||||
DBConnector connector;
|
Connection connection;
|
||||||
String cognitoID;
|
String cognitoID;
|
||||||
|
|
||||||
private final String GET_ITEM_MATCHES = "SELECT * FROM Product WHERE description LIKE ?";
|
private final String GET_ITEM_MATCHES = "SELECT * FROM Product WHERE description LIKE ? LIMIT 100;";
|
||||||
|
|
||||||
public ItemSearcher(DBConnector connector, String cognitoID) {
|
public ItemSearcher(Connection connection, String cognitoID) {
|
||||||
this.connector = connector;
|
this.connection = connection;
|
||||||
this.cognitoID = cognitoID;
|
this.cognitoID = cognitoID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object conductAction(Map<String, Object> body, HashMap<String, String> queryParams, String s) throws SQLException {
|
public Object conductAction(Map<String, Object> body, HashMap<String, String> queryParams, String s) throws SQLException {
|
||||||
try (Connection connection = connector.getConnection()) {
|
PreparedStatement getItemMatches = connection.prepareStatement(GET_ITEM_MATCHES);
|
||||||
PreparedStatement getItemMatches = connection.prepareStatement(GET_ITEM_MATCHES);
|
getItemMatches.setString(1, "%" + queryParams.get("id") + "%");
|
||||||
getItemMatches.setString(1, "%" + queryParams.get("id") + "%");
|
System.out.println(getItemMatches);
|
||||||
System.out.println(getItemMatches);
|
ResultSet searchResults = getItemMatches.executeQuery();
|
||||||
ResultSet searchResults = getItemMatches.executeQuery();
|
ItemSearch searchResultsObject = new ItemSearch(searchResults);
|
||||||
ItemSearch searchResultsObject = new ItemSearch(searchResults);
|
System.out.println(searchResultsObject);
|
||||||
System.out.println(searchResultsObject);
|
return searchResultsObject;
|
||||||
return searchResultsObject;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user