From 276adf93ffeb4e71a6fd06a181c2ec629a50007e Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 12 May 2014 11:25:20 +0200 Subject: Fix status reporting --- src/main/Main.java | 4 +++- src/main/Watcher.java | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/Main.java b/src/main/Main.java index e7fc372..43e5619 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -111,7 +111,9 @@ public class Main implements Callable { private boolean tweetsToDb(ITweetReader reader) throws IOException { Tweet tweet = null; tweetNo = 1; + System.err.println("Trying to establish DB connection..."); try (Connection connection = cb.create()) { + System.err.println("Connected, starting to read tweets."); /* create the object that fills the database */ DataFiller filler = new DataFiller(connection); while ((tweet = reader.getTweet()) != null) { @@ -137,7 +139,7 @@ public class Main implements Callable { public int getProcessedTweets() { // tweetNo is the tweet number of the tweet that is being processed. - return Math.min(0, tweetNo - 1); + return Math.max(0, tweetNo - 1); } @Override diff --git a/src/main/Watcher.java b/src/main/Watcher.java index bb790f0..6032095 100644 --- a/src/main/Watcher.java +++ b/src/main/Watcher.java @@ -29,6 +29,11 @@ class Watcher implements Runnable { @Override public void run() { int newCount = main.getProcessedTweets(); + if (newCount < 1) { + // database connection is being established? Whatever is the case, + // no status information should be printed. + return; + } int tweets_per_min = (newCount - previousCount) * 60 / interval; int tweets_per_sec = tweets_per_min / 60; elapsed_seconds += interval; -- cgit v1.2.1