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

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 { public class SchedulerComments {
private static final Integer COUNT = 100; 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 static final Pattern PATTERN = Pattern.compile("@[\\w]+");
private final CommentService commentService; 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.dto.bitbucket.CommentJson;
import org.sadtech.bot.bitbucketbot.service.Utils; import org.sadtech.bot.bitbucketbot.service.Utils;
import java.security.SecureRandom;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@RequiredArgsConstructor @RequiredArgsConstructor
public class Seeker implements Callable<Optional<ResultScan>> { public class Seeker implements Callable<Optional<ResultScan>> {
private static final SecureRandom random = new SecureRandom();
private final DataScan dataScan; private final DataScan dataScan;
private final String token; private final String token;
@Override @Override
public Optional<ResultScan> call() throws Exception { public Optional<ResultScan> call() {
// Thread.sleep(random.nextInt(500) + 500L);
return Utils.urlToJson(dataScan.getUrlComment(), token, CommentJson.class) return Utils.urlToJson(dataScan.getUrlComment(), token, CommentJson.class)
.map(commentJson -> new ResultScan(dataScan.getUrlComment(), dataScan.getUrlPr(), commentJson)); .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> { public class ExecutorScanner implements Executor<DataScan, ResultScan> {
private final ExecutorService executorService; 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; private final BitbucketConfig bitbucketConfig;
@Override @Override
public boolean registration(@NonNull List<DataScan> dataScans) { public boolean registration(@NonNull List<DataScan> dataScans) {
dataScans.stream() resultList.addAll(
.map(dataScan -> new Seeker(dataScan, bitbucketConfig.getToken())) dataScans.stream()
.forEach(seeker -> executorService.submit(seeker)); .map(dataScan -> new Seeker(dataScan, bitbucketConfig.getToken()))
.map(executorService::submit)
.collect(Collectors.toList())
);
return true; return true;
} }

View File

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