From 2073e69034c0f93b0e472a8dba2d061b970ba85a Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 2 Jul 2014 11:29:50 +0200 Subject: [PATCH] fix for long periods in timeline --- htroot/api/timeline_p.java | 18 +++++++++--------- source/net/yacy/search/EventTracker.java | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htroot/api/timeline_p.java b/htroot/api/timeline_p.java index 783ff5056..a22bac185 100644 --- a/htroot/api/timeline_p.java +++ b/htroot/api/timeline_p.java @@ -54,16 +54,16 @@ public final class timeline_p { // get type of data to be listed in the timeline int maxeventsperperiod = post.getInt("head", 1); // the maximum number of events per period String period = post.get("period", ""); // must be an integer with a character c at the end, c = Y|M|d|h|m|s - int periodlength = 0; + long periodlength = 0; if (period.length() > 0) { char c = period.charAt(period.length() - 1); - int p = Integer.parseInt(period.substring(0, period.length() - 1)); - if (c == 's') periodlength = p * 1000; - else if (c == 'm') periodlength = p * 1000 * 60; - else if (c == 'h') periodlength = p * 1000 * 60 * 60; - else if (c == 'd') periodlength = p * 1000 * 60 * 60 * 24; - else if (c == 'M') periodlength = p * 1000 * 60 * 60 * 24 * 30; - else if (c == 'Y') periodlength = p * 1000 * 60 * 60 * 24 * 365; + long p = Long.parseLong(period.substring(0, period.length() - 1)); + if (c == 's') periodlength = p * 1000L; + else if (c == 'm') periodlength = p * 1000L * 60L; + else if (c == 'h') periodlength = p * 1000L * 60L * 60L; + else if (c == 'd') periodlength = p * 1000L * 60L * 60L * 24L; + else if (c == 'M') periodlength = p * 1000L * 60L * 60L * 24L * 30L; + else if (c == 'Y' || c == 'y') periodlength = p * 1000L * 60L * 60L * 24L * 365L; else periodlength = 0; } final String[] data = post.get("data", "").split(","); // a string of word hashes that shall be searched and combined @@ -131,7 +131,7 @@ public final class timeline_p { return prop; } - private static void stats(OrderedScoreMap accumulation, List eap, long startDate, int periodlength, int head, String type) { + private static void stats(OrderedScoreMap accumulation, List eap, long startDate, long periodlength, int head, String type) { // write accumulation of the score map into eap Iterator si = accumulation.keys(false); int c = 0; diff --git a/source/net/yacy/search/EventTracker.java b/source/net/yacy/search/EventTracker.java index 2fba99a11..2479e285c 100644 --- a/source/net/yacy/search/EventTracker.java +++ b/source/net/yacy/search/EventTracker.java @@ -131,17 +131,17 @@ public class EventTracker { public final static class Event { final private Object time; // either a String in SHORT_SECOND format, a Long with ms since epoch or Date; - final public int duration; // ms + final public long duration; // ms final public String type; final public Object payload; final public int count; - public Event(final Date time, final int duration, final String type, final Object payload, final int count) { + public Event(final Date time, final long duration, final String type, final Object payload, final int count) { this.time = time; this.duration = duration; this.type = type; this.payload = payload; this.count = count; } - public Event(final Long time, final int duration, final String type, final Object payload, final int count) { + public Event(final Long time, final long duration, final String type, final Object payload, final int count) { this.time = time; this.duration = duration; this.type = type; this.payload = payload; this.count = count; } - public Event(final String time, final int duration, final String type, final Object payload, final int count) { + public Event(final String time, final long duration, final String type, final Object payload, final int count) { this.time = time; this.duration = duration; this.type = type; this.payload = payload; this.count = count; } public String getFormattedDate() {