diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java index 6dc1726..4c6a6e0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java @@ -15,33 +15,33 @@ import java.util.Map; public interface StatsRepository extends CrudRepository { - @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> viewsByMonths(); + @Query("select new map(to_char(r.releaseDate, 'month') as label, sum(r.views) as y) from Research r where r.author.id = ?1 group by to_char(r.releaseDate, 'month')") + Iterable> viewsByMonths(long researcherId); @Query("select new map(to_char(r.releaseDate,'YYYY') as label, sum (r.views) as y) from Research r group by to_char(r.releaseDate,'YYYY')") - Iterable> viewsByYears(); + Iterable> viewsByYears(long researcherId); - @Query("select new map(r.domain as label, sum(r.views) as y) from Research r group by r.domain") - Iterable> viewsByTopics(); + @Query("select new map(r.domain as label, sum(r.views) as y) from Research r where r.author.id = ?1 group by r.domain") + Iterable> viewsByTopics(long researcherId); - @Query("select new map(r.domain as label, count(distinct r.language) as y) from Research r group by r.domain") - Iterable> languageByTopics(); + @Query("select new map(r.domain as label, count(distinct r.language) as y) from Research r where r.author.id = ?1 group by r.domain") + Iterable> languageByTopics(long researcherId); - @Query("select new map(to_char(r.releaseDate,'YYYY') as label, count(distinct r.language) as y) from Research r group by to_char(r.releaseDate,'YYYY')") - Iterable> languageByYears(); + @Query("select new map(to_char(r.releaseDate,'YYYY') as label, count(distinct r.language) as y) from Research r where r.author.id = ?1 group by to_char(r.releaseDate,'YYYY')") + Iterable> languageByYears(long researcherId); - @Query("select new map(to_char(r.releaseDate, 'month') as label, count(distinct r.language) as y) from Research r group by to_char(r.releaseDate, 'month')") - Iterable> languageByMonths(); + @Query("select new map(to_char(r.releaseDate, 'month') as label, count(distinct r.language) as y) from Research r where r.author.id = ?1 group by to_char(r.releaseDate, 'month')") + Iterable> languageByMonths(long researcherId); - @Query("select new map(to_char(r.releaseDate,'YYYY') as label, count(distinct r) as y) from Research r group by to_char(r.releaseDate,'YYYY')") - Iterable> researchesByYears(); + @Query("select new map(to_char(r.releaseDate,'YYYY') as label, count(distinct r) as y) from Research r where r.author.id = ?1 group by to_char(r.releaseDate,'YYYY')") + Iterable> researchesByYears(long researcherId); - @Query("select new map(r.domain as label, count(distinct r) as y) from Research r group by r.domain") - Iterable> researchesByTopics(); + @Query("select new map(r.domain as label, count(distinct r) as y) from Research r where r.author.id = ?1 group by r.domain") + Iterable> researchesByTopics(long researcherId); - @Query("select new map(to_char(r.releaseDate, 'month') as label, count(distinct r) as y) from Research r group by to_char(r.releaseDate, 'month')") - Iterable> researchesByMonth(); + @Query("select new map(to_char(r.releaseDate, 'month') as label, count(distinct r) as y) from Research r where r.author.id = ?1 group by to_char(r.releaseDate, 'month')") + Iterable> researchesByMonth(long researcherId); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/StatisticsService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/StatisticsService.java index 350feca..9f47466 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/StatisticsService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/StatisticsService.java @@ -34,17 +34,17 @@ public class StatisticsService { ArrayList>> toReturn = new ArrayList<>(); - toReturn.add(statsRepo.viewsByYears()); - toReturn.add(statsRepo.viewsByMonths()); - toReturn.add(statsRepo.viewsByTopics()); + toReturn.add(statsRepo.viewsByYears(researcher.getId())); + toReturn.add(statsRepo.viewsByMonths(researcher.getId())); + toReturn.add(statsRepo.viewsByTopics(researcher.getId())); - toReturn.add(statsRepo.researchesByYears()); - toReturn.add(statsRepo.researchesByMonth()); - toReturn.add(statsRepo.researchesByTopics()); + toReturn.add(statsRepo.researchesByYears(researcher.getId())); + toReturn.add(statsRepo.researchesByMonth(researcher.getId())); + toReturn.add(statsRepo.researchesByTopics(researcher.getId())); - toReturn.add(statsRepo.languageByYears()); - toReturn.add(statsRepo.languageByMonths()); - toReturn.add(statsRepo.languageByTopics()); + toReturn.add(statsRepo.languageByYears(researcher.getId())); + toReturn.add(statsRepo.languageByMonths(researcher.getId())); + toReturn.add(statsRepo.languageByTopics(researcher.getId())); return toReturn; } } \ No newline at end of file diff --git a/frontend/src/Apps/ScientificPublications/ListResearches.vue b/frontend/src/Apps/ScientificPublications/ListResearches.vue index d056f72..67bae6d 100644 --- a/frontend/src/Apps/ScientificPublications/ListResearches.vue +++ b/frontend/src/Apps/ScientificPublications/ListResearches.vue @@ -136,6 +136,7 @@ const emit = defineEmits(["modified"]);