From 952f869f594e027b5c7e14628aa1bcb17ee26f9e Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 21 Jun 2021 14:19:42 +0200 Subject: [PATCH 1/2] Improve logging for MatchesListForumUpdater --- .classpath | 44 ------------------- .project | 23 ---------- .../MatchesListForumUpdater.java | 8 +++- 3 files changed, 7 insertions(+), 68 deletions(-) delete mode 100644 .classpath delete mode 100644 .project diff --git a/.classpath b/.classpath deleted file mode 100644 index f0257c5..0000000 --- a/.classpath +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index a338e31..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - tlw-database-tool - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java index bc58356..de32a45 100644 --- a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java @@ -1,12 +1,17 @@ package de.jeyp91.tippligaforum; +import de.jeyp91.App; import de.jeyp91.apifootball.APIFootballUpdater; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashSet; public class MatchesListForumUpdater { private HashSet leagues; + private static final Logger logger = LogManager.getLogger(MatchesListForumUpdater.class); public MatchesListForumUpdater() { this.leagues = new APIFootballUpdater().getLeagues(); @@ -36,7 +41,8 @@ public class MatchesListForumUpdater { rset.next(); postId = Integer.parseInt(rset.getString(1)); } catch (SQLException e) { - e.printStackTrace(); + logger.error("Could not find post for " + country + " - " + league + "."); + logger.error(e.getMessage()); } return postId; } From 1c99d0a4681b983cd51233e050311ca99691740e Mon Sep 17 00:00:00 2001 From: Julian Date: Tue, 22 Jun 2021 16:13:37 +0200 Subject: [PATCH 2/2] Only update forum posts if post id was found --- .../de/jeyp91/tippligaforum/MatchesListForumUpdater.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java index de32a45..bd03062 100644 --- a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java @@ -27,9 +27,11 @@ public class MatchesListForumUpdater { MatchesListCreator creator = new MatchesListCreator(league); String content = creator.getMatchesBeautiful(); String contentWithCodeBBCode = "[code]" + content + "[/code]"; - int postId = getPostId(creator.getCountry(), creator.getLeagueName()); - TippligaSQLConnector con = TippligaSQLConnector.getInstance(); - con.updatePost(postId, contentWithCodeBBCode); + Integer postId = getPostId(creator.getCountry(), creator.getLeagueName()); + if(postId != null) { + TippligaSQLConnector con = TippligaSQLConnector.getInstance(); + con.updatePost(postId, contentWithCodeBBCode); + } } private Integer getPostId(String country, String league) {