1
0
forked from PGL/Clyde

added stats SQL queries

This commit is contained in:
Bartha Maxime 2024-04-16 11:54:11 +02:00
parent f184de21a8
commit 87b02af68e
2 changed files with 26 additions and 4 deletions

View File

@ -11,17 +11,30 @@ public interface StatsRepository extends CrudRepository<Research,Long> {
@Query("select new map(to_char(r.releaseDate, 'month') as label, sum(r.views) as y) from Research r group by to_char(r.releaseDate, 'month')")
Iterable<Map<String ,Integer>> viewsByMonths();
/**
@Query("select new map(to_char(r.releaseDate,'year') as label, sum (r.views) as y) from Research r group by to_char(r.releaseDate,'year')")
Iterable<Map<String ,Integer>> viewsByYears();
@Query("select new map(r.domain as label, sum(r.views) as y) from Research r group by r.domain")
Iterable<Map<String ,Integer>> viewsByTopics();
Iterable<Map<String ,Integer>> coAuthorByMonths();
Iterable<Map<String ,Integer>> coAuthorsByTopics();
@Query("select new map(r.domain as label, r.language as y) from Research r group by r.domain")
Iterable<Map<String ,Integer>> languageByTopics();
@Query("select new map(to_char(r.releaseDate,'year') as label, r.language as y) from Research r group by to_char(r.releaseDate,'year')")
Iterable<Map<String ,Integer>> languageByYears();
@Query("select new map(to_char(r.releaseDate, 'month') as label, r.language as y) from Research r group by to_char(r.releaseDate, 'month')")
Iterable<Map<String ,Integer>> languageByMonths();
@Query("select new map(to_char(r.releaseDate,'year') as label, count(r) as y) from Research r group by to_char(r.releaseDate,'year')")
Iterable<Map<String ,Integer>> researchesByYears();
@Query("select new map(r.domain as label, count(r) as y) from Research r group by r.domain")
Iterable<Map<String ,Integer>> researchesByTopics();
@Query("select new map(to_char(r.releaseDate, 'month') as label, count(r) as y) from Research r group by to_char(r.releaseDate, 'month')")
Iterable<Map<String ,Integer>> researchesByMonth();
**/
}

View File

@ -29,8 +29,17 @@ public class StatisticsService {
ArrayList<Iterable<Map<String,Integer>>> toReturn = new ArrayList<>();
toReturn.add(statsRepo.viewsByYears());
toReturn.add(statsRepo.viewsByMonths());
toReturn.add(statsRepo.viewsByTopics());
toReturn.add(statsRepo.researchesByYears());
toReturn.add(statsRepo.researchesByMonth());
toReturn.add(statsRepo.researchesByTopics());
toReturn.add(statsRepo.languageByYears());
toReturn.add(statsRepo.languageByMonths());
toReturn.add(statsRepo.languageByTopics());
return toReturn;
}