Небольшое исправление
This commit is contained in:
parent
6b8fd45937
commit
8b62e1e63d
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user