added stats SQL queries
This commit is contained in:
		@ -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();
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user