From d10b8719435849ad902f313ac6cb09ea7fbbb3ec Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 31 Mar 2023 01:36:10 -0400 Subject: [PATCH] Fix another UI bug and delete expired autorecs automatically --- src/main/java/com/moparisthebest/rcrdit/RcrdIt.java | 12 +++--------- src/main/webapp/js/rcrdit.js | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java b/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java index e5bca1a..a9cca43 100644 --- a/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java +++ b/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java @@ -398,15 +398,9 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable { QueryMapper qm = new QueryMapper(conn)) { log.debug("Database connected!"); final Map profileMap = qm.toMap("SELECT profile_id, name, folder, run_at_recording_start, run_at_recording_finish FROM profile", new HashMap<>(), Integer.class, Profile.class); - //System.out.println(profileMap); - /* - try(java.sql.ResultSet rs = qm.toResultSet("SELECT profile_id, priority, title, channel_name, days_of_week AS daysOfWeekString, between_time_start AS betweenTimeStartTime, between_time_end AS betweenTimeEndTime, time_min AS timeMinDate, time_max AS timeMaxDate FROM autorecs")) { - for(int x = 1; x <= rs.getMetaData().getColumnCount(); ++x) { - System.out.println(rs.getMetaData().getColumnName(x)); - System.out.println(rs.getMetaData().getColumnLabel(x)); - } - } - */ + // delete old autorecs + final int autoRecsDeleted = qm.executeUpdate("DELETE FROM autorecs WHERE time_max < ?", java.sql.Timestamp.from(Instant.now())); + log.debug("expired autorecs deleted: {}", autoRecsDeleted); autoRecs.clear(); qm.toCollection("SELECT profile_id, priority, title, channel_name, days_of_week, between_time_start, between_time_end, time_min, time_max FROM autorecs", autoRecs, AutoRec.class); autoRecs.forEach(a -> a.setProfile(profileMap.get(a.getProfileId()))); diff --git a/src/main/webapp/js/rcrdit.js b/src/main/webapp/js/rcrdit.js index 671c0d9..7d7b4b5 100644 --- a/src/main/webapp/js/rcrdit.js +++ b/src/main/webapp/js/rcrdit.js @@ -562,12 +562,12 @@ function validateProgramRecordDialog(advancedRecordMode){ var effectiveEndText = $("#effectiveEndText").val(); var effectiveEndTimestamp = moment(effectiveEndText,["MM/DD/YYYY hh:mm"]).unix(); - if(isNaN(effectiveBeginTimestamp) && !isNull(effectiveBeginText)){ + if(isNaN(effectiveBeginTimestamp) && !isEmpty(effectiveBeginText)){ toastr["error"]("Effective Begin entry is not valid!"); $("#effectiveBeginText").addClass("entryError"); error = true; } - if(isNaN(effectiveEndTimestamp) && !isNull(effectiveEndText)){ + if(isNaN(effectiveEndTimestamp) && !isEmpty(effectiveEndText)){ toastr["error"]("Effective End entry is not valid!"); $("#effectiveEndText").addClass("entryError"); error = true;