diff --git a/src/main/java/de/holarse/backend/db/repositories/NodeAwareRepository.java b/src/main/java/de/holarse/backend/db/repositories/NodeAwareRepository.java index 696302a4..5097673f 100644 --- a/src/main/java/de/holarse/backend/db/repositories/NodeAwareRepository.java +++ b/src/main/java/de/holarse/backend/db/repositories/NodeAwareRepository.java @@ -9,18 +9,28 @@ public interface NodeAwareRepository { @Query("SELECT nextval('node_sequence')") - int nextNodeId(); + int nextNodeId(); - @Query(value = "SELECT to_char(np.accessed, 'YYYY-MM-DD') as time, sum(1) as amount from node_pagevisits np " + - "WHERE np.nodeid = :nodeId and np.accessed >= now() - interval '1 day' * :days " + - "GROUP BY to_char(np.accessed, 'YYYY-MM-DD') " + - "ORDER BY to_char(np.accessed, 'YYYY-MM-DD')", nativeQuery = true) + @Query(value = "select to_char(stdate, 'YYYY-MM-DD') as time, " + + "count(np.nodeid) as amount " + + "from generate_series(cast((now() - interval '1 day' * :days) as date), " + + " cast(now() as date), " + + " interval '1 day') as stdate " + + "left join node_pagevisits np on cast(np.accessed as date) = stdate " + + "where (np.nodeid = :nodeId or np.nodeid is null) " + + "group by to_char(stdate, 'YYYY-MM-DD') " + + "order by to_char(stdate, 'YYYY-MM-DD')", nativeQuery = true) List getDailyStats(@Param("nodeId") final Integer nodeId, @Param("days") final int days); - @Query(value = "SELECT to_char(np.accessed, 'YYYY-MM') as time, sum(1) as amount from node_pagevisits np " + - "WHERE np.nodeid = :nodeId and np.accessed >= now() - interval '1 month' * :months " + - "GROUP BY to_char(np.accessed, 'YYYY-MM') " + - "ORDER BY to_char(np.accessed, 'YYYY-MM')", nativeQuery = true) + @Query(value = "select to_char(stdate, 'YYYY-MM') as time, " + + "count(np.nodeid) as amount " + + "from generate_series(cast((now() - interval '1 month' * :months) as date), " + + " cast(now() as date), " + + " interval '1 day') as stdate " + + "left join node_pagevisits np on cast(np.accessed as date) = stdate " + + "where (np.nodeid = :nodeId or np.nodeid is null) " + + "group by to_char(stdate, 'YYYY-MM') " + + "order by to_char(stdate, 'YYYY-MM')", nativeQuery = true) List getMonthlyStats(@Param("nodeId") final Integer nodeId, @Param("months") final int months); diff --git a/src/main/webapp/WEB-INF/templates/sites/wiki/stats.html b/src/main/webapp/WEB-INF/templates/sites/wiki/stats.html index 977bd0ce..de39ce1a 100644 --- a/src/main/webapp/WEB-INF/templates/sites/wiki/stats.html +++ b/src/main/webapp/WEB-INF/templates/sites/wiki/stats.html @@ -7,7 +7,7 @@

Lorem ipsum sta
- +
@@ -18,7 +18,7 @@

Lorem ipsum sta

- +
Zugriffe auf den Artikel