Add post checksum mode
This commit is contained in:
@@ -22,7 +22,7 @@ public class App {
|
||||
private static int season;
|
||||
private static int league;
|
||||
private static String configFile;
|
||||
private static Logger logger = LogManager.getLogger(App.class);
|
||||
private static final Logger logger = LogManager.getLogger(App.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Configurator.setRootLevel(Level.INFO);
|
||||
@@ -56,6 +56,17 @@ public class App {
|
||||
MatchesListForumUpdater matchesListForumUpdater = new MatchesListForumUpdater();
|
||||
matchesListForumUpdater.updateAllLeagues();
|
||||
break;
|
||||
case "PostChecksum":
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
int forumId;
|
||||
if (season == 2021) {
|
||||
forumId = 15;
|
||||
} else {
|
||||
throw new Exception("Season does not exist");
|
||||
}
|
||||
String checksum = con.getChecksumOfPost(forumId, configFile);
|
||||
System.out.println(checksum);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -76,7 +87,7 @@ public class App {
|
||||
|
||||
parser.addArgument("-m", "--mode")
|
||||
.dest("mode")
|
||||
.choices("MatchdaysUpdater", "MatchesCreatorFootball", "MatchesUpdaterFootball", "TeamsUpdater", "APIFootballUpdater", "MatchesListGistUpdater")
|
||||
.choices("MatchdaysUpdater", "MatchesCreatorFootball", "MatchesUpdaterFootball", "TeamsUpdater", "APIFootballUpdater", "MatchesListGistUpdater", "PostChecksum")
|
||||
.help("")
|
||||
.required(true)
|
||||
.type(String.class);
|
||||
|
||||
@@ -210,6 +210,20 @@ public class TippligaSQLConnector {
|
||||
executeUpdate(query);
|
||||
}
|
||||
|
||||
public String getChecksumOfPost(int forum_id, String subject) {
|
||||
String queryString = "SELECT post_checksum FROM phpbb_posts WHERE forum_id = " + forum_id + " AND post_subject = '" + subject + "'";
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
String checksum = null;
|
||||
try {
|
||||
while (rset.next()) {
|
||||
checksum = rset.getString(1);
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getPostUpdateQuery(int postId, String postText, String postChecksum, long postEditTime, String postEditReason, int postEditUser) {
|
||||
return "UPDATE phpbb_posts SET " +
|
||||
"post_text = '" + postText + "', " +
|
||||
|
||||
Reference in New Issue
Block a user