Clean up DAO
This commit is contained in:
parent
8bd3c31f53
commit
9a6c8339d0
@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
public class EdgeDataStoreDaoImpl implements EdgeDataStoreDao {
|
public class EdgeDataStoreDaoImpl implements EdgeDataStoreDao {
|
||||||
@ -266,18 +265,26 @@ public class EdgeDataStoreDaoImpl implements EdgeDataStoreDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BrowseResult> getBrowseResultFromUrlIds(List<EdgeId<EdgeUrl>> urlId) {
|
public List<BrowseResult> getBrowseResultFromUrlIds(List<EdgeId<EdgeUrl>> urlIds) {
|
||||||
if (urlId.isEmpty())
|
if (urlIds.isEmpty())
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
List<BrowseResult> ret = new ArrayList<>(urlId.size());
|
List<BrowseResult> ret = new ArrayList<>(urlIds.size());
|
||||||
|
|
||||||
try (var conn = dataSource.getConnection()) {
|
try (var conn = dataSource.getConnection()) {
|
||||||
try (var stmt = conn.createStatement()) {
|
try (var stmt = conn.createStatement()) {
|
||||||
// this is safe, string concatenation is of integers
|
|
||||||
String inStmt = urlId.stream().map(id -> Integer.toString(id.id())).collect(Collectors.joining(", ", "(", ")"));
|
|
||||||
|
|
||||||
var rsp = stmt.executeQuery("SELECT DOMAIN_ID, DOMAIN_NAME FROM EC_URL_VIEW INNER JOIN DOMAIN_METADATA ON EC_URL_VIEW.DOMAIN_ID=DOMAIN_METADATA.ID WHERE KNOWN_URLS<5000 AND QUALITY>-10 AND EC_URL_VIEW.ID IN " + inStmt);
|
String inStmt = idList(urlIds);
|
||||||
|
|
||||||
|
var rsp = stmt.executeQuery("""
|
||||||
|
SELECT DOMAIN_ID, DOMAIN_NAME
|
||||||
|
FROM EC_URL_VIEW
|
||||||
|
INNER JOIN DOMAIN_METADATA ON EC_URL_VIEW.DOMAIN_ID=DOMAIN_METADATA.ID
|
||||||
|
WHERE
|
||||||
|
KNOWN_URLS<5000
|
||||||
|
AND QUALITY>-10
|
||||||
|
AND EC_URL_VIEW.ID IN
|
||||||
|
""" + inStmt); // this injection is safe, inStmt is derived from concatenating a list of integers
|
||||||
while (rsp.next()) {
|
while (rsp.next()) {
|
||||||
int id = rsp.getInt(1);
|
int id = rsp.getInt(1);
|
||||||
String domain = rsp.getString(2);
|
String domain = rsp.getString(2);
|
||||||
|
Loading…
Reference in New Issue
Block a user