Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 35ca17d

Browse files
committed
Merge branch 'issue862'
Conflicts: app/controllers/SearchController.java
2 parents e42d1f9 + 7e3daa5 commit 35ca17d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

app/controllers/SearchController.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.graylog2.restclient.models.api.results.DateHistogramResult;
3939
import org.graylog2.restclient.models.api.results.SearchResult;
4040
import org.joda.time.DateTime;
41-
import org.joda.time.DateTimeConstants;
4241
import org.joda.time.Minutes;
4342
import play.mvc.Result;
4443
import views.helpers.Permissions;
@@ -139,10 +138,10 @@ public Result index(String q,
139138
protected String determineHistogramResolution(final SearchResult searchResult) {
140139
final String interval;
141140
final int queryRangeInMinutes = Minutes.minutesBetween(searchResult.getFromDateTime(), searchResult.getToDateTime()).getMinutes();
142-
final int HOUR = DateTimeConstants.MINUTES_PER_HOUR;
143-
final int DAY = DateTimeConstants.MINUTES_PER_DAY;
144-
final int WEEK = DateTimeConstants.MINUTES_PER_WEEK;
145-
final int MONTH = DAY * 30;
141+
final int HOUR = 60;
142+
final int DAY = HOUR * 24;
143+
final int WEEK = DAY * 7;
144+
final int MONTH = HOUR * 24 * 30;
146145
final int YEAR = MONTH * 12;
147146

148147
if (queryRangeInMinutes < DAY / 2) {

app/views/helpers/DateHistogramResolutionSelector.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package views.helpers;
22

3+
import com.google.common.base.Charsets;
34
import com.google.common.collect.Maps;
45
import org.apache.commons.lang3.text.WordUtils;
56

67
import lib.SearchTools;
78
import play.mvc.Http;
89

10+
import java.io.UnsupportedEncodingException;
911
import java.util.Map;
1012

1113
public class DateHistogramResolutionSelector {
@@ -23,11 +25,17 @@ public static String getOptions(String selected, Http.Request request) {
2325
url.append("?");
2426

2527
for (Map.Entry<String, String[]> entry : queryParams.entrySet()) {
28+
2629
for (String value : entry.getValue()) {
27-
url.append(entry.getKey())
28-
.append("=")
29-
.append(value)
30-
.append("&");
30+
try {
31+
url.append(entry.getKey())
32+
.append("=")
33+
.append(java.net.URLEncoder.encode(value, Charsets.UTF_8.name()))
34+
.append("&");
35+
} catch (UnsupportedEncodingException e) {
36+
// UTF-8 *is* supported, but just in case...
37+
throw new RuntimeException(e);
38+
}
3139
}
3240
}
3341

0 commit comments

Comments
 (0)