Небольшое исправление

This commit is contained in:
upagge 2020-06-17 19:13:54 +03:00
parent 6b8fd45937
commit 8b62e1e63d
No known key found for this signature in database
GPG Key ID: 15CD012E46F6BA34
4 changed files with 10 additions and 10 deletions

View File

@ -40,7 +40,7 @@ import java.util.stream.Collectors;
public class SchedulerComments {
private static final Integer COUNT = 100;
private static final Integer NO_COMMENT = 6;
private static final Integer NO_COMMENT = 20;
private static final Pattern PATTERN = Pattern.compile("@[\\w]+");
private final CommentService commentService;

View File

@ -4,20 +4,17 @@ import lombok.RequiredArgsConstructor;
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
import org.sadtech.bot.bitbucketbot.service.Utils;
import java.security.SecureRandom;
import java.util.Optional;
import java.util.concurrent.Callable;
@RequiredArgsConstructor
public class Seeker implements Callable<Optional<ResultScan>> {
private static final SecureRandom random = new SecureRandom();
private final DataScan dataScan;
private final String token;
@Override
public Optional<ResultScan> call() throws Exception {
// Thread.sleep(random.nextInt(500) + 500L);
public Optional<ResultScan> call() {
return Utils.urlToJson(dataScan.getUrlComment(), token, CommentJson.class)
.map(commentJson -> new ResultScan(dataScan.getUrlComment(), dataScan.getUrlPr(), commentJson));
}

View File

@ -24,14 +24,17 @@ import java.util.stream.Collectors;
public class ExecutorScanner implements Executor<DataScan, ResultScan> {
private final ExecutorService executorService;
private final List<Future<Optional<ResultScan>>> resultList = new ArrayList<>();
private List<Future<Optional<ResultScan>>> resultList = new ArrayList<>();
private final BitbucketConfig bitbucketConfig;
@Override
public boolean registration(@NonNull List<DataScan> dataScans) {
dataScans.stream()
.map(dataScan -> new Seeker(dataScan, bitbucketConfig.getToken()))
.forEach(seeker -> executorService.submit(seeker));
resultList.addAll(
dataScans.stream()
.map(dataScan -> new Seeker(dataScan, bitbucketConfig.getToken()))
.map(executorService::submit)
.collect(Collectors.toList())
);
return true;
}

View File

@ -18,7 +18,7 @@
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>