mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-22 13:35:42 -05:00
#2742 Events tab: decode events from all channels stored in the database
- EventManager collects decode events from all channels (tracked by identity, re-checked for in-place updates) and saves/broadcasts EventRecord snapshots for the Events tab and future API subscribers. - Schema version 3: events and event_patched_talkgroups tables; IEventRepository/EventRepository for H2, MariaDB and PostgreSQL. - Events tab after Calls: paging, page size, talkgroup/radio alias search, category, event type, protocol, system, details and date filters, live updates, talkgroup hold context menu. - Aliases resolved at display time from the stored alias list name (shared IdentifierRecord base with calls, SqlSupport filter helpers). - Database switch transfers events; event age-off rule (default 30 days) in the database preferences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* their recordings, after the retention period (default 1 hour).</li>
|
||||
* <li>Age rule: removes calls older than a number of days.</li>
|
||||
* <li>Size rule: removes the oldest recordings when the total size of the recordings exceeds a limit.</li>
|
||||
* <li>Event rule: deletes decode events older than a number of days (enabled by default, 30 days).</li>
|
||||
* </ul>
|
||||
* The age and size rules either delete the call row and its recording file, or delete only the recording file and
|
||||
* keep the call row.
|
||||
@@ -138,12 +139,13 @@ public class AgeOffManager
|
||||
RetentionPeriod retention = mPreference.getDuplicateDoNotMonitorRetention();
|
||||
|
||||
if(database == null || (!retention.isEnabled() && !mPreference.isAgeRuleEnabled() &&
|
||||
!mPreference.isSizeRuleEnabled()))
|
||||
!mPreference.isSizeRuleEnabled() && !mPreference.isEventRuleEnabled()))
|
||||
{
|
||||
return new AgeOffResult(0, 0, 0);
|
||||
return new AgeOffResult(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0);
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0, 0);
|
||||
long events = 0;
|
||||
|
||||
try(Connection connection = database.getConnection())
|
||||
{
|
||||
@@ -166,6 +168,19 @@ public class AgeOffManager
|
||||
long limit = mPreference.getSizeRuleLimitMB() * BYTES_PER_MB;
|
||||
result = result.add(applySizeRule(connection, repository, limit, mPreference.getSizeRuleAction()));
|
||||
}
|
||||
|
||||
if(mPreference.isEventRuleEnabled())
|
||||
{
|
||||
long cutoff = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(mPreference.getEventRuleDays());
|
||||
events = database.getEventRepository().deleteStartedBefore(connection, cutoff);
|
||||
result = result.add(new AgeOffResult(0, 0, 0, events));
|
||||
}
|
||||
}
|
||||
|
||||
if(events > 0)
|
||||
{
|
||||
LOGGER.info("Event age-off removed " + events + " events");
|
||||
mDatabaseManager.notifyEventsChanged();
|
||||
}
|
||||
|
||||
if(result.calls() > 0 || result.recordings() > 0)
|
||||
@@ -185,7 +200,7 @@ public class AgeOffManager
|
||||
static AgeOffResult applyRetentionRule(Connection connection, ICallRepository repository, long cutoff)
|
||||
throws SQLException
|
||||
{
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0);
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0, 0);
|
||||
List<CallRecord> page = repository.getDuplicateAndDoNotMonitorCalls(connection, cutoff, PAGE_SIZE);
|
||||
|
||||
while(!page.isEmpty())
|
||||
@@ -203,7 +218,7 @@ public class AgeOffManager
|
||||
static AgeOffResult applyAgeRule(Connection connection, ICallRepository repository, long cutoff,
|
||||
AgeOffAction action) throws SQLException
|
||||
{
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0);
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0, 0);
|
||||
List<CallRecord> page = action == AgeOffAction.DELETE_CALL_AND_RECORDING ?
|
||||
repository.getCallsStartedBefore(connection, cutoff, PAGE_SIZE) :
|
||||
repository.getRecordedCalls(connection, cutoff, PAGE_SIZE);
|
||||
@@ -226,7 +241,7 @@ public class AgeOffManager
|
||||
static AgeOffResult applySizeRule(Connection connection, ICallRepository repository, long limitBytes,
|
||||
AgeOffAction action) throws SQLException
|
||||
{
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0);
|
||||
AgeOffResult result = new AgeOffResult(0, 0, 0, 0);
|
||||
long total = repository.getRecordedFileSize(connection);
|
||||
|
||||
while(total > limitBytes)
|
||||
@@ -281,11 +296,11 @@ public class AgeOffManager
|
||||
if(action == AgeOffAction.DELETE_CALL_AND_RECORDING)
|
||||
{
|
||||
repository.delete(connection, ids);
|
||||
return new AgeOffResult(ids.size(), recordings, bytes);
|
||||
return new AgeOffResult(ids.size(), recordings, bytes, 0);
|
||||
}
|
||||
|
||||
repository.markRecordingsDeleted(connection, ids);
|
||||
return new AgeOffResult(0, recordings, bytes);
|
||||
return new AgeOffResult(0, recordings, bytes, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,12 +333,14 @@ public class AgeOffManager
|
||||
* @param calls deleted
|
||||
* @param recordings deleted
|
||||
* @param bytes of recordings deleted
|
||||
* @param events deleted
|
||||
*/
|
||||
public record AgeOffResult(long calls, long recordings, long bytes)
|
||||
public record AgeOffResult(long calls, long recordings, long bytes, long events)
|
||||
{
|
||||
public AgeOffResult add(AgeOffResult other)
|
||||
{
|
||||
return new AgeOffResult(calls + other.calls, recordings + other.recordings, bytes + other.bytes);
|
||||
return new AgeOffResult(calls + other.calls, recordings + other.recordings, bytes + other.bytes,
|
||||
events + other.events);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user