Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for DownloadStats #272

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/jivesoftware/site/DiscourseAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public DownloadStatsRunnable(Map<Integer, Long> counts) {
}

public void run() {
Log.info("Retrieving Discourse statistics...");
Log.debug("Retrieving Discourse statistics...");

Instant start = Instant.now();
final Map<Integer, Long> results = new HashMap<>();
Expand All @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jivesoftware/site/DownloadServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jivesoftware/site/DownloadStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public DownloadStatsRunnable(Map<String, Long> counts) {
}

public void run() {
Log.info("Retrieving downloads statistics...");
Log.debug("Retrieving downloads statistics...");

final DbConnectionManager connectionManager = DbConnectionManager.getInstance();
Connection con = null;
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/main/webapp/includes/sidebar_7daySnapshot.jspf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="ignite_sidebar_body">
<c:if test="${downloadsLast7Days gt 0}">
<div class="ignite_sidebar_body_stat">
<span>Recent Downloads</span> <strong><fmt:formatNumber value="${downloadsLast7Days}"/></strong>
<span>Downloads</span> <strong><fmt:formatNumber value="${downloadsLast7Days}"/></strong>
</div>
</c:if>

Expand All @@ -32,6 +32,9 @@
<%-- <strong><%= blogService48.getBlogPostCount() %></strong>--%>
<%-- </div>--%>
</cache:cache>
<div class="ignite_sidebar_body_stat">
<em>Activity in last 7 days</em>
</div>
</div>
<div class="ignite_sidebar_btm"></div>
</div>
2 changes: 1 addition & 1 deletion src/main/webapp/includes/sidebar_snapshot.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
Loading