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

View File

@ -17,5 +17,5 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> findAllByIdIn(List<Integer> paperIds); 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) { public List<Paper> findAllCompletedByType(Paper.PaperType type) {
return paperRepository.findByType(type) return paperRepository.findByTypeAndStatus(type, Paper.PaperStatus.COMPLETED);
.stream()
.filter(findAllCompleted()::contains)
.collect(toList());
} }
} }

View File

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