Skip to content

Commit

Permalink
Fixes for DownloadStats
Browse files Browse the repository at this point in the history
Better alignment in CSS.
Hopefully, per-project stats now work.
  • Loading branch information
guusdk committed Sep 19, 2024
1 parent 5899825 commit d72dde7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
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
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

0 comments on commit d72dde7

Please sign in to comment.