-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Logging von nodeId für wiki, Stats für wiki
- Loading branch information
Bernd Ritter
committed
May 3, 2024
1 parent
e6e7e4a
commit 09f129c
Showing
7 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
19 changes: 18 additions & 1 deletion
19
src/main/java/de/holarse/backend/db/repositories/NodeAwareRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
package de.holarse.backend.db.repositories; | ||
|
||
import de.holarse.backend.view.NodeStatisticsView; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface NodeAwareRepository { | ||
|
||
@Query("SELECT nextval('node_sequence')") | ||
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) | ||
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) | ||
List<NodeStatisticsView> getMonthlyStats(@Param("nodeId") final Integer nodeId, @Param("months") final int months); | ||
|
||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/de/holarse/backend/types/StatIntervalType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.holarse.backend.types; | ||
|
||
public enum StatIntervalType { | ||
|
||
// Statistiken in täglicher Auflösung | ||
daily, | ||
// Statistiken in monatlicher Auflösung | ||
monthly | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/de/holarse/backend/view/NodeStatisticsView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.holarse.backend.view; | ||
|
||
public interface NodeStatisticsView { | ||
|
||
String getTime(); | ||
Integer getAmount(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div class="row justify-content-center"> | ||
<div class="col-sm-10"> | ||
<div class="u-shadow-v21 g-bg-white rounded"> | ||
|
||
<header class="u-heading-v2-1--bottom g-mb-30"> | ||
<h2 class="u-heading-v2__title g-mb-10" data-th-text="${title1}">Lorem ipsum standard</h2> | ||
</header> | ||
<section> | ||
<div class="table-responsive"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Zeit</th> | ||
<th>Zugriffe</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr data-th-each="stat : ${stats}"> | ||
<td data-th-text="${stat.time}"></td> | ||
<td data-th-text="${stat.amount}"></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
</div> |