fix: cache refresh
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 7m10s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 7m10s
This commit is contained in:
parent
2501b998fa
commit
2d883ca1da
@ -755,94 +755,87 @@ public class ResultService {
|
||||
List<CardModel> cards = new java.util.ArrayList<>();
|
||||
|
||||
//noinspection unchecked
|
||||
cacheClubClassement.invalidateIf(
|
||||
(p) -> ((Pair<Long, List<ClubClassement>>) p).getKey() > System.currentTimeMillis());
|
||||
return cacheClubClassement.invalidateIf(
|
||||
(p) -> ((Pair<Long, List<ClubClassement>>) p).getKey() > System.currentTimeMillis())
|
||||
.chain(__ -> cache ? Uni.createFrom().voidItem() : cacheClubClassement.invalidate(uuid))
|
||||
.chain(o -> cacheClubClassement.getAsync(uuid, k -> cardRepository.list("competition.uuid = ?1", uuid)
|
||||
.invoke(__ -> System.out.println("Cache miss for club classement with uuid " + uuid))
|
||||
.invoke(cards::addAll)
|
||||
.chain(__ -> matchRepository.list("category.compet.uuid = ?1", uuid))
|
||||
.chain(matchs -> {
|
||||
HashMap<CategoryModel, List<MatchModel>> map = new HashMap<>();
|
||||
for (MatchModel match : matchs) {
|
||||
if (!map.containsKey(match.getCategory()))
|
||||
map.put(match.getCategory(), new java.util.ArrayList<>());
|
||||
map.get(match.getCategory()).add(match);
|
||||
}
|
||||
|
||||
if (!cache)
|
||||
cacheClubClassement.invalidate(uuid);
|
||||
return Multi.createFrom().iterable(map.entrySet())
|
||||
.onItem().call(entry -> Mutiny.fetch(entry.getKey().getTree()))
|
||||
.map(entry -> {
|
||||
ResultCategoryData tmp = new ResultCategoryData();
|
||||
|
||||
return cacheClubClassement.getAsync(uuid, k -> cardRepository.list("competition.uuid = ?1", uuid)
|
||||
.invoke(__ -> System.out.println("Cache miss for club classement with uuid " + uuid))
|
||||
.invoke(cards::addAll)
|
||||
.chain(__ -> matchRepository.list("category.compet.uuid = ?1", uuid))
|
||||
.chain(matchs -> {
|
||||
HashMap<CategoryModel, List<MatchModel>> map = new HashMap<>();
|
||||
for (MatchModel match : matchs) {
|
||||
if (!map.containsKey(match.getCategory()))
|
||||
map.put(match.getCategory(), new java.util.ArrayList<>());
|
||||
map.get(match.getCategory()).add(match);
|
||||
}
|
||||
getArray2(entry.getValue().stream().map(m -> new MatchModelExtend(m, cards))
|
||||
.toList(),
|
||||
null, tmp);
|
||||
getClassementArray(entry.getKey(), null, cards, tmp);
|
||||
|
||||
return Multi.createFrom().iterable(map.entrySet())
|
||||
.onItem().call(entry -> Mutiny.fetch(entry.getKey().getTree()))
|
||||
.map(entry -> {
|
||||
ResultCategoryData tmp = new ResultCategoryData();
|
||||
return tmp;
|
||||
})
|
||||
.collect().asList();
|
||||
})
|
||||
.map(categoryData -> {
|
||||
HashMap<String, ClubClassement> clubMap = new HashMap<>();
|
||||
|
||||
getArray2(entry.getValue().stream().map(m -> new MatchModelExtend(m, cards)).toList(),
|
||||
null, tmp);
|
||||
getClassementArray(entry.getKey(), null, cards, tmp);
|
||||
categoryData.forEach(
|
||||
c -> c.getClassement().stream().map(ResultCategoryData.ClassementData::comb)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(comb -> {
|
||||
if (comb instanceof MembreModel membreModel2) {
|
||||
return (membreModel2.getClub() != null) ? membreModel2.getClub()
|
||||
.getName() : "";
|
||||
} else if (comb instanceof CompetitionGuestModel guestModel) {
|
||||
return guestModel.getClub();
|
||||
}
|
||||
return "";
|
||||
})
|
||||
.filter(s -> s != null && !s.isBlank() && !s.equals("Team"))
|
||||
.distinct()
|
||||
.forEach(clubName -> clubMap.putIfAbsent(clubName,
|
||||
new ClubClassement(clubName))));
|
||||
|
||||
return tmp;
|
||||
})
|
||||
.collect().asList();
|
||||
})
|
||||
.map(categoryData -> {
|
||||
HashMap<String, ClubClassement> clubMap = new HashMap<>();
|
||||
categoryData.forEach(c -> c.getClassement().forEach(classementData -> {
|
||||
if (classementData.rank() > 3)
|
||||
return;
|
||||
|
||||
categoryData.forEach(c -> c.getClassement().stream().map(ResultCategoryData.ClassementData::comb)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(comb -> {
|
||||
if (comb instanceof MembreModel membreModel2) {
|
||||
return (membreModel2.getClub() != null) ? membreModel2.getClub().getName() : "";
|
||||
} else if (comb instanceof CompetitionGuestModel guestModel) {
|
||||
return guestModel.getClub();
|
||||
if (classementData.comb() != null) {
|
||||
String clubName = "";
|
||||
if (classementData.comb() instanceof MembreModel membreModel2) {
|
||||
clubName = (membreModel2.getClub() != null) ? membreModel2.getClub()
|
||||
.getName() : "";
|
||||
} else if (classementData.comb() instanceof CompetitionGuestModel guestModel) {
|
||||
clubName = guestModel.getClub();
|
||||
}
|
||||
|
||||
if (clubName != null && !clubName.isBlank()
|
||||
&& !clubName.equals("Team") && clubMap.containsKey(clubName)) {
|
||||
ClubClassement entity = clubMap.get(clubName);
|
||||
entity.score[classementData.rank() - 1]++;
|
||||
entity.tt_score += 4 - classementData.rank();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
})
|
||||
.filter(s -> s != null && !s.isBlank() && !s.equals("Team"))
|
||||
.distinct()
|
||||
.forEach(clubName -> clubMap.putIfAbsent(clubName, new ClubClassement(clubName))));
|
||||
}));
|
||||
|
||||
System.out.println(clubMap.keySet());
|
||||
|
||||
categoryData.forEach(c -> c.getClassement().forEach(classementData -> {
|
||||
System.out.println("Classement data for " + c.getName() + ": " + classementData.name() + " - " +
|
||||
classementData.comb() + " - " + classementData.rank());
|
||||
if (classementData.rank() > 3)
|
||||
return;
|
||||
|
||||
System.out.println(
|
||||
"Processing classement data for " + c.getName() + ": " + classementData.name());
|
||||
|
||||
if (classementData.comb() != null) {
|
||||
String clubName = "";
|
||||
if (classementData.comb() instanceof MembreModel membreModel2) {
|
||||
clubName = (membreModel2.getClub() != null) ? membreModel2.getClub().getName() : "";
|
||||
} else if (classementData.comb() instanceof CompetitionGuestModel guestModel) {
|
||||
clubName = guestModel.getClub();
|
||||
}
|
||||
System.out.println("-> " + clubName + "- " + (clubName != null && !clubName.isBlank()
|
||||
&& !clubName.equals("Team") && clubMap.containsKey(clubName)));
|
||||
|
||||
if (clubName != null && !clubName.isBlank()
|
||||
&& !clubName.equals("Team") && clubMap.containsKey(clubName)) {
|
||||
ClubClassement entity = clubMap.get(clubName);
|
||||
entity.score[classementData.rank() - 1]++;
|
||||
entity.tt_score += 4 - classementData.rank();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return clubMap.values().stream()
|
||||
.sorted(Comparator.comparingInt((ClubClassement c) -> c.tt_score)
|
||||
.thenComparingInt(c -> c.score[0])
|
||||
.thenComparingInt(c -> c.score[1])
|
||||
.thenComparingInt(c -> c.score[2]).reversed())
|
||||
.toList();
|
||||
})
|
||||
.map(l -> new Pair<>(System.currentTimeMillis() + 60 * 1000L, l))
|
||||
).map(Pair::getValue);
|
||||
return clubMap.values().stream()
|
||||
.sorted(Comparator.comparingInt((ClubClassement c) -> c.tt_score)
|
||||
.thenComparingInt(c -> c.score[0])
|
||||
.thenComparingInt(c -> c.score[1])
|
||||
.thenComparingInt(c -> c.score[2]).reversed())
|
||||
.toList();
|
||||
})
|
||||
.map(l -> new Pair<>(System.currentTimeMillis() + 60 * 1000L, l))
|
||||
).map(Pair::getValue));
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user