reduced total amount of sentences, removed time constraint, deleting more now, added as experiment to run response threads with a 2 thread pool

This commit is contained in:
christian 2021-12-13 15:05:09 +01:00
parent 8b25e6e8f9
commit 7e9d830c42
2 changed files with 15 additions and 10 deletions

View File

@ -89,15 +89,14 @@ public class DataMapper {
ResultSet l_rsSearch = null; ResultSet l_rsSearch = null;
String CountSQL = "select count(*) from Sentences"; String CountSQL = "select count(*) from Sentences";
String l_sSQL = "delete from Sentences\n" + String l_sSQL = "delete from Sentences\n" +
" where DATE(last_used) < DATE_SUB(CURDATE(), INTERVAL 10 DAY)\n" + " order by last_used asc limit 5";
" order by last_used asc limit 2";
try { try {
l_cCon = DBCPDataSource.getConnection(); l_cCon = DBCPDataSource.getConnection();
l_pStatement = l_cCon.prepareStatement(CountSQL); l_pStatement = l_cCon.prepareStatement(CountSQL);
ResultSet resultSet = l_pStatement.executeQuery(); ResultSet resultSet = l_pStatement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
int count = resultSet.getInt(1); int count = resultSet.getInt(1);
if (count > 8500) { if (count > 7000) {
l_pStatement = l_cCon.prepareStatement(l_sSQL); l_pStatement = l_cCon.prepareStatement(l_sSQL);
l_pStatement.execute(); l_pStatement.execute();
} }

View File

@ -90,6 +90,7 @@ public class DiscordHandler extends ListenerAdapter {
private static Datahandler datahandler; private static Datahandler datahandler;
private static StanfordCoreNLP stanfordCoreNLPSentiment; private static StanfordCoreNLP stanfordCoreNLPSentiment;
private static ExecutorService executorService = Executors.newFixedThreadPool(1); private static ExecutorService executorService = Executors.newFixedThreadPool(1);
private static ExecutorService executorServiceResponse = Executors.newFixedThreadPool(2);
private static ExecutorService executorServiceIngame = Executors.newFixedThreadPool(2); private static ExecutorService executorServiceIngame = Executors.newFixedThreadPool(2);
//TODO add python program that edits the java code. python program just adds test if statements on //TODO add python program that edits the java code. python program just adds test if statements on
@ -167,13 +168,18 @@ public class DiscordHandler extends ListenerAdapter {
} }
} }
if (mentionedBot || channelName.contains("general-autism")) { if (mentionedBot || channelName.contains("general-autism")) {
String ResponseStr; final String contentF = content;
ResponseStr = datahandler.getResponseMsg(content, username, stanfordCoreNLP, stanfordCoreNLPSentiment, executorServiceResponse.execute(new Runnable() {
false); @Override
if (!ResponseStr.isEmpty()) { public void run() {
System.out.print("\nResponseStr3: " + ResponseStr + "\n"); String ResponseStr = datahandler.getResponseMsg(contentF, username, stanfordCoreNLP, stanfordCoreNLPSentiment,
event.getMessage().getChannel().sendMessage(ResponseStr).queue(); false);
} if (!ResponseStr.isEmpty()) {
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
event.getMessage().getChannel().sendMessage(ResponseStr).queue();
}
}
});
} else { } else {
final String contentF = content; final String contentF = content;
executorService.execute(new Runnable() { executorService.execute(new Runnable() {