Skip to content

Commit

Permalink
Stats enthalten nun alle Zwischentage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Ritter committed May 23, 2024
1 parent f0ce719 commit 4201089
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeStatisticsView> 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<NodeStatisticsView> getMonthlyStats(@Param("nodeId") final Integer nodeId, @Param("months") final int months);


Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/templates/sites/wiki/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2 class="u-heading-v2__title g-mb-10" data-th-text="${title1}">Lorem ipsum sta
</header>
<section>
<div id="article-chart">
<table class="charts-css column show-labels show-primary-axis">
<table class="charts-css column show-heading show-labels show-primary-axis data-outside">
<caption>Zugriffe auf den Artikel</caption>
<thead>
<tr>
Expand All @@ -18,7 +18,7 @@ <h2 class="u-heading-v2__title g-mb-10" data-th-text="${title1}">Lorem ipsum sta
<tbody>
<tr data-th-each="stat : ${stats}">
<th scope="row" data-th-text="${stat.time}"></th>
<td data-th-style="'--size: calc(' + ${stat.amount} + '/100.0);'"><span class="data" data-th-text="${stat.amount}"></span></td>
<td data-th-style="'--size: calc(' + ${stat.amount} + '/100.0);'"><span class="data outside" data-th-text="${stat.amount}"></span></td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 4201089

Please sign in to comment.