#117 resolve discussions v.2

This commit is contained in:
T-Midnight 2019-05-02 21:56:54 +04:00
parent b334b5d70e
commit de625923e9
4 changed files with 11 additions and 24 deletions

View File

@ -19,7 +19,6 @@ import ru.ulstu.user.model.User;
import ru.ulstu.user.service.UserService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@ -209,16 +208,11 @@ public class GrantService {
private List<User> getCompletedPapersAuthors(Paper.PaperType type) {
List<Paper> papers = paperService.findAllCompletedByType(type);
papers.stream()
return papers.stream()
.filter(paper -> paper.getAuthors() != null)
.flatMap(paper -> paper.getAuthors().stream())
.collect(toList());
List<User> users = new ArrayList<>();
for (Paper p : papers) {
p.getAuthors()
.stream()
.forEach(users::add);
}
return users;
}
private List<User> getBAKAuthors() {
@ -229,14 +223,10 @@ public class GrantService {
}
private List<User> getScopusAuthors() {
List<User> oldAuthors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS);
List<User> newAuthors = new ArrayList<>();
oldAuthors.forEach(author -> {
int count = Collections.frequency(oldAuthors, author);
if (count > 3) {
newAuthors.add(author);
}
});
return newAuthors;
List<User> authors = getCompletedPapersAuthors(Paper.PaperType.SCOPUS);
return authors
.stream()
.filter(author -> Collections.frequency(authors, author) > 3)
.collect(toList());
}
}

View File

@ -17,5 +17,5 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> findAllByIdIn(List<Integer> paperIds);
List<Paper> findByType(Paper.PaperType type);
List<Paper> findByTypeAndStatus(Paper.PaperType type, Paper.PaperStatus status);
}

View File

@ -305,9 +305,6 @@ public class PaperService {
}
public List<Paper> findAllCompletedByType(Paper.PaperType type) {
return paperRepository.findByType(type)
.stream()
.filter(findAllCompleted()::contains)
.collect(toList());
return paperRepository.findByTypeAndStatus(type, Paper.PaperStatus.COMPLETED);
}
}

View File

@ -1,7 +1,7 @@
# Server Settings
spring.main.banner-mode=off
server.port=8443
server.http.port=8080
server.http.port=8888
spring.http.multipart.maxFileSize=20MB
spring.http.multipart.maxRequestSize=20MB
# Thymeleaf Settings