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

Bugs in downloadstats #271

Merged
merged 2 commits into from
Sep 19, 2024
Merged
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
23 changes: 14 additions & 9 deletions src/main/java/org/jivesoftware/site/DownloadStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,17 @@ public void run() {
results.put(TOTAL, total);

// Combine Openfire and Wildfire results (as they're different historical names for the same project).
results.put(DownloadServlet.DownloadInfo.openfire.getName(), results.get(DownloadServlet.DownloadInfo.openfire.getName()) + results.get(DownloadServlet.DownloadInfo.wildfire.getName()));
results.remove(DownloadServlet.DownloadInfo.wildfire.getName());
results.put(DownloadServlet.DownloadInfo.openfire_plugin.getName(), results.get(DownloadServlet.DownloadInfo.openfire_plugin.getName()) + results.get(DownloadServlet.DownloadInfo.wildfire_plugin.getName()));
results.remove(DownloadServlet.DownloadInfo.wildfire_plugin.getName());

results.forEach((key, value) -> System.out.println(key + ": " + value));
if (results.containsKey(DownloadServlet.DownloadInfo.wildfire.getName()))
{
final long added = results.containsKey(DownloadServlet.DownloadInfo.openfire.getName()) ? results.get(DownloadServlet.DownloadInfo.openfire.getName()) + results.get(DownloadServlet.DownloadInfo.wildfire.getName()) : results.get(DownloadServlet.DownloadInfo.wildfire.getName());
results.put(DownloadServlet.DownloadInfo.openfire.getName(), added);
results.remove(DownloadServlet.DownloadInfo.wildfire.getName());
}
if (results.containsKey(DownloadServlet.DownloadInfo.wildfire_plugin.getName())) {
final long added = results.containsKey(DownloadServlet.DownloadInfo.openfire.getName()) ? results.get(DownloadServlet.DownloadInfo.openfire.getName()) + results.get(DownloadServlet.DownloadInfo.wildfire_plugin.getName()) : results.get(DownloadServlet.DownloadInfo.wildfire_plugin.getName());
results.put(DownloadServlet.DownloadInfo.openfire_plugin.getName(), added);
results.remove(DownloadServlet.DownloadInfo.wildfire_plugin.getName());
}

rs.close();
pstmt.close();
Expand Down Expand Up @@ -293,7 +298,7 @@ public static void addListingToDatabase( String ipAddress, String product, Strin
{
// Correct for X-Forwarded-For header value sometimes containing a list of IPs. Use the last one.
if (ipAddress != null && ipAddress.contains(",")) {
ipAddress = ipAddress.substring(ipAddress.indexOf(",")+1).trim();
ipAddress = ipAddress.substring(ipAddress.lastIndexOf(",")+1).trim();
}

final DbConnectionManager connectionManager = DbConnectionManager.getInstance();
Expand Down Expand Up @@ -360,7 +365,7 @@ public static void addUpdateToDatabase( String ipAddress, String product, String
{
// Correct for X-Forwarded-For header value sometimes containing a list of IPs. Use the last one.
if (ipAddress != null && ipAddress.contains(",")) {
ipAddress = ipAddress.substring(ipAddress.indexOf(",")+1).trim();
ipAddress = ipAddress.substring(ipAddress.lastIndexOf(",")+1).trim();
}

final DbConnectionManager connectionManager = DbConnectionManager.getInstance();
Expand Down Expand Up @@ -417,7 +422,7 @@ public static void addCheckUpdate( String ipAddress, String os, String currentVe
{
// Correct for X-Forwarded-For header value sometimes containing a list of IPs. Use the last one.
if (ipAddress != null && ipAddress.contains(",")) {
ipAddress = ipAddress.substring(ipAddress.indexOf(",")+1).trim();
ipAddress = ipAddress.substring(ipAddress.lastIndexOf(",")+1).trim();
}

final DbConnectionManager connectionManager = DbConnectionManager.getInstance();
Expand Down
Loading