From d72dde78e5bf33c58212c62752efc2250d6cebad Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 19 Sep 2024 14:10:38 +0200 Subject: [PATCH 1/2] Fixes for DownloadStats Better alignment in CSS. Hopefully, per-project stats now work. --- .../java/org/jivesoftware/site/DownloadServlet.java | 11 +++++++++++ src/main/webapp/includes/sidebar_7daySnapshot.jspf | 5 ++++- src/main/webapp/includes/sidebar_snapshot.jsp | 2 +- src/main/webapp/styles/global.css | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jivesoftware/site/DownloadServlet.java b/src/main/java/org/jivesoftware/site/DownloadServlet.java index 5e9f73ca..915fe8be 100644 --- a/src/main/java/org/jivesoftware/site/DownloadServlet.java +++ b/src/main/java/org/jivesoftware/site/DownloadServlet.java @@ -8,6 +8,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.Arrays; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -58,6 +59,16 @@ public String getName() { return name; } + public static DownloadInfo forName(String name) + { + return Arrays.stream(DownloadInfo.values()).filter(d -> d.getName().equals(name)).findFirst().orElse(null); + } + + public static DownloadInfo forType(int type) + { + return Arrays.stream(DownloadInfo.values()).filter(d -> d.getType() == type).findFirst().orElse(null); + } + public static DownloadInfo getDownloadInfo(int type) { switch (type) { diff --git a/src/main/webapp/includes/sidebar_7daySnapshot.jspf b/src/main/webapp/includes/sidebar_7daySnapshot.jspf index 2a01952a..bf9ee53c 100644 --- a/src/main/webapp/includes/sidebar_7daySnapshot.jspf +++ b/src/main/webapp/includes/sidebar_7daySnapshot.jspf @@ -13,7 +13,7 @@
- Recent Downloads + Downloads
@@ -32,6 +32,9 @@ <%-- <%= blogService48.getBlogPostCount() %>--%> <%--
--%> +
+ Activity in last 7 days +
diff --git a/src/main/webapp/includes/sidebar_snapshot.jsp b/src/main/webapp/includes/sidebar_snapshot.jsp index b88ba9e0..09ef8167 100644 --- a/src/main/webapp/includes/sidebar_snapshot.jsp +++ b/src/main/webapp/includes/sidebar_snapshot.jsp @@ -10,7 +10,7 @@ long downloads = 0; try { - downloads = DownloadStats.getDownloadsForType(DownloadServlet.DownloadInfo.valueOf(project)); + downloads = DownloadStats.getDownloadsForType(DownloadServlet.DownloadInfo.forName(project)); } catch (Exception e) { LoggerFactory.getLogger( "sidebar_snapshot.jsp" ).debug( "An exception occurred that can probably be ignored.", e); } diff --git a/src/main/webapp/styles/global.css b/src/main/webapp/styles/global.css index b070655a..4056af05 100644 --- a/src/main/webapp/styles/global.css +++ b/src/main/webapp/styles/global.css @@ -873,6 +873,10 @@ div.ignite_sidebar_body_stat span { div.ignite_sidebar_body_stat strong { float: right; } +div.ignite_sidebar_body_stat em { + padding-left: 1em; + padding-top: 0.5em; + } /* quote sidebar (in your words) */ From f2c5e6617d9b72efaf61e7a6dba6fe44094cb3d8 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 19 Sep 2024 14:13:49 +0200 Subject: [PATCH 2/2] Modified log messages a little --- src/main/java/org/jivesoftware/site/DiscourseAPI.java | 4 ++-- src/main/java/org/jivesoftware/site/DownloadStats.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jivesoftware/site/DiscourseAPI.java b/src/main/java/org/jivesoftware/site/DiscourseAPI.java index 497d0e1c..e4f9584e 100644 --- a/src/main/java/org/jivesoftware/site/DiscourseAPI.java +++ b/src/main/java/org/jivesoftware/site/DiscourseAPI.java @@ -119,7 +119,7 @@ public DownloadStatsRunnable(Map counts) { } public void run() { - Log.info("Retrieving Discourse statistics..."); + Log.debug("Retrieving Discourse statistics..."); Instant start = Instant.now(); final Map results = new HashMap<>(); @@ -131,7 +131,7 @@ public void run() { if (b != null) { results.put(4, b); } - Log.debug("Queried all Discourse stats in {}", Duration.between(start, Instant.now())); + Log.info("Queried all Discourse stats in {}", Duration.between(start, Instant.now())); // Replace all values in the object used by the website in one go. counts.clear(); diff --git a/src/main/java/org/jivesoftware/site/DownloadStats.java b/src/main/java/org/jivesoftware/site/DownloadStats.java index be5201ef..07a6738a 100644 --- a/src/main/java/org/jivesoftware/site/DownloadStats.java +++ b/src/main/java/org/jivesoftware/site/DownloadStats.java @@ -190,7 +190,7 @@ public DownloadStatsRunnable(Map counts) { } public void run() { - Log.info("Retrieving downloads statistics..."); + Log.debug("Retrieving downloads statistics..."); final DbConnectionManager connectionManager = DbConnectionManager.getInstance(); Connection con = null; @@ -254,7 +254,7 @@ public void run() { rs.close(); pstmt.close(); - Log.debug("Queried all download stats in {}", Duration.between(start, Instant.now())); + Log.info("Queried all-time download stats in {}", Duration.between(start, Instant.now())); start = Instant.now(); pstmt = con.prepareStatement(COUNT_TOTAL_DOWNLOADS_LAST_7_DAYS); @@ -264,7 +264,7 @@ public void run() { lastDays = rs.getLong(1); } results.put(TOTAL7DAYS, lastDays); - Log.debug("Queried last 7 days download stats in {}", Duration.between(start, Instant.now())); + Log.info("Queried last 7 days download stats in {}", Duration.between(start, Instant.now())); // Replace all values in the object used by the website in one go. counts.clear();