From 334c70c37af7965d230d8f3c52b50b3060a9774f Mon Sep 17 00:00:00 2001 From: reger Date: Mon, 20 Feb 2017 00:14:14 +0100 Subject: [PATCH] correct fromDate init value on missing param in api/timeline_p servlet revert test modification from last commit in AccessTracker.main --- htroot/api/timeline_p.java | 6 +++--- source/net/yacy/search/query/AccessTracker.java | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htroot/api/timeline_p.java b/htroot/api/timeline_p.java index b9e4991b0..c531a510b 100644 --- a/htroot/api/timeline_p.java +++ b/htroot/api/timeline_p.java @@ -75,9 +75,9 @@ public final class timeline_p { // get a time period Date fromDate = new Date(0); Date toDate = new Date(); - try {fromDate = GenericFormatter.SHORT_SECOND_FORMATTER.parse(post.get("from", "20031215182700"), 0).getTime();} catch (ParseException e) {} - try {toDate = GenericFormatter.SHORT_SECOND_FORMATTER.parse(post.get("to", GenericFormatter.SHORT_SECOND_FORMATTER.format(new Date())), 0).getTime();} catch (ParseException e) {} - + try {fromDate = GenericFormatter.SHORT_SECOND_FORMATTER.parse(post.get("from", GenericFormatter.SHORT_SECOND_FORMATTER.format(fromDate)), 0).getTime();} catch (ParseException e) {} + try {toDate = GenericFormatter.SHORT_SECOND_FORMATTER.parse(post.get("to", GenericFormatter.SHORT_SECOND_FORMATTER.format(toDate)), 0).getTime();} catch (ParseException e) {} + // get latest dump; AccessTracker.dumpLog(); diff --git a/source/net/yacy/search/query/AccessTracker.java b/source/net/yacy/search/query/AccessTracker.java index 55c3a40cb..46b017626 100644 --- a/source/net/yacy/search/query/AccessTracker.java +++ b/source/net/yacy/search/query/AccessTracker.java @@ -342,15 +342,15 @@ public class AccessTracker { public static void main(String[] args) { // i.e. /Users/admin/git/rc1/DATA/LOG/queries.log 20140522135156 20140614223118 - String file = "C:\\src\\github\\yacy_search_server\\DATA\\LOG\\queries.log"; + String file = args[0]; Date from; - // try { - from = new Date(0);//GenericFormatter.SHORT_SECOND_FORMATTER.parse(args[1], 0).getTime(); - Date to = new Date();//GenericFormatter.SHORT_SECOND_FORMATTER.parse(args[2], 0).getTime(); + try { + from = GenericFormatter.SHORT_SECOND_FORMATTER.parse(args[1], 0).getTime(); + Date to = GenericFormatter.SHORT_SECOND_FORMATTER.parse(args[2], 0).getTime(); List dump = readLog(new File(file), from, to); for (EventTracker.Event s: dump) System.out.println(s.toString()); - // } catch (ParseException e) { - // e.printStackTrace(); - // } + } catch (ParseException e) { + e.printStackTrace(); + } } }