#27 -- fix performance

This commit is contained in:
Anton Romanov 2021-04-30 10:11:20 +04:00
parent 49e906c190
commit ccde75abc6
2 changed files with 23 additions and 16 deletions

View File

@ -41,61 +41,58 @@ public class StatisticController {
.map(tc -> tc[0].toString().substring(tc[0].toString().lastIndexOf("/") + 1))
.collect(Collectors.toList());
model.addAttribute("urls", urls);
model.addAttribute("commitEntityData", entityCommits());
model.addAttribute("commitEntityData", getEntityCommits());
model.addAttribute("commitTimeEntityData", allTimeEntityCommits());
return STATISTIC;
}
public List<Object[]> authorCommits() {
List<Object[]> authorCommits = commitRepository.getCommitAuthorStatistic().stream()
return commitRepository.getCommitAuthorStatistic().stream()
.map(stat -> new Object[]{stat.getAuthor(), stat.getCountCommit()})
.collect(Collectors.toList());
return authorCommits;
}
public List<Object[]> getUrlCommits() {
List<Object[]> urlCommits = commitRepository.getCommitUrlStatistic().stream()
return commitRepository.getCommitUrlStatistic().stream()
.map(stat -> new Object[]{stat.getUrl(), stat.getCountCommit()})
.collect(Collectors.toList());
return urlCommits;
}
public List<Object[]> getTimeCommits() {
List<Object[]> timeCommits = commitRepository.getCommitTimeStatistic().stream()
return commitRepository.getCommitTimeStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
return timeCommits;
}
public List<Object[]> entityCommits() {
public List<Object[]> getEntityCommits() {
List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
.map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
.collect(Collectors.toList());
for (int i = 0; i < entityCommits.size(); i++) {
entityCommits.get(i)[0] = Boolean.TRUE.equals(entityCommits.get(i)[0])
for (Object[] entityCommit : entityCommits) {
entityCommit[0] = Boolean.TRUE.equals(entityCommit[0])
? "Есть сущности"
: (entityCommits.get(i)[0] == null
: (entityCommit[0] == null
? "Нет данных"
: "Нет сущностей");
}
return entityCommits;
}
public List<Object[]> timeEntityCommits() {
List<Object[]> timeEntityCommits = commitRepository.getCommitTimeEntityStatistic().stream()
public List<Object[]> getTimeEntityCommits() {
return commitRepository.getCommitTimeEntityStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
return timeEntityCommits;
}
public List<Object[]> allTimeEntityCommits() {
List<Object[]> timeEntityCommits = getTimeEntityCommits();
List<Object[]> allTimeEntityCommits = commitRepository.getCommitTimeStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
int j = 0;
for (int i = 0; i < allTimeEntityCommits.size(); i++) {
if ((j < timeEntityCommits().size()) && (allTimeEntityCommits.get(i)[0].equals(timeEntityCommits().get(j)[0]))) {
allTimeEntityCommits.get(i)[1] = timeEntityCommits().get(j)[1];
if ((j < timeEntityCommits.size()) && (allTimeEntityCommits.get(i)[0].equals(timeEntityCommits.get(j)[0]))) {
allTimeEntityCommits.get(i)[1] = timeEntityCommits.get(j)[1];
j++;
} else {
if (i > 0) {

View File

@ -54,4 +54,14 @@
referencedTableName="branch" referencedColumnNames="id" onDelete="CASCADE"
onUpdate="CASCADE"/>
</changeSet>
<changeSet author="orion" id="20210430-100000-1">
<sql>
CREATE INDEX commit_branch_idx ON public.commit
USING hash (branch_id);
CREATE INDEX file_change_commit_idx ON public.file_change
USING hash (commit_id);
CREATE INDEX line_change_file_change_idx ON public.line_change
USING hash (file_change_id);
</sql>
</changeSet>
</databaseChangeLog>