fix request

This commit is contained in:
Eduard Tihomiorv 2025-10-09 11:56:40 +03:00
parent c0c3ce00e5
commit 200a8a0e4a

View file

@ -131,6 +131,8 @@ public class DownloadService {
String url = response.getSql();
String paramName = response.getParamName();
Collection<List<String>> pages = partitionList(response.getParams(), limit);
url = url.replaceAll(";(?=[^;]*$)", " ") + " LIMIT " + limit + " OFFSET "
+ offset + ";";
for (List<String> page : pages) {
pageIndex++;
String resultSet = "(" + page.stream()
@ -139,10 +141,10 @@ public class DownloadService {
url = url.replace("${" + paramName + "}",
resultSet
);
url = url.replaceAll(";(?=[^;]*$)", " ") + " LIMIT " + limit + " OFFSET "
+ offset + ";";
String newUrl = url;
int newOffset = offset;
while (true) {
results = new ArrayList<>(executeSqlQuery(connection, url));
results = new ArrayList<>(executeSqlQuery(connection, newUrl));
if (results.size() <= 1) {
break;
}
@ -151,10 +153,10 @@ public class DownloadService {
if (results.size() - 1 < limit) {
break;
}
String oldPagination = " OFFSET " + offset + ";";
offset += limit;
String newPagination = " OFFSET " + offset + ";";
url = url.replace(oldPagination, newPagination);
String oldPagination = " OFFSET " + newOffset + ";";
newOffset += limit;
String newPagination = " OFFSET " + newOffset + ";";
newUrl = newUrl.replace(oldPagination, newPagination);
pageIndex++;
}
}