From f14e0e3a727a7982055ab3a435ea50724a789a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Pantale=C3=A3o?= <5808343+bgoncal@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:04:26 +0100 Subject: [PATCH] Add extra logging for database updates --- Sources/Shared/API/Models/AppEntitiesModel.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/Shared/API/Models/AppEntitiesModel.swift b/Sources/Shared/API/Models/AppEntitiesModel.swift index f66c9f81f..6f6a2c033 100644 --- a/Sources/Shared/API/Models/AppEntitiesModel.swift +++ b/Sources/Shared/API/Models/AppEntitiesModel.swift @@ -24,11 +24,19 @@ public final class AppEntitiesModel: AppEntitiesModelProtocol { // First check for time to avoid unecessary filtering to check count if !checkLastDatabaseUpdateLessThanMinuteAgo() { let appRelatedEntities = filterDomains(entities) + Current.Log + .verbose( + "Updating App Entities for \(server.info.name) checkLastDatabaseUpdateLessThanMinuteAgo false, lastDatabaseUpdate \(String(describing: lastDatabaseUpdate)) " + ) updateLastUpdate(entitiesCount: appRelatedEntities.count) handle(appRelatedEntities: appRelatedEntities, server: server) } else { let appRelatedEntities = filterDomains(entities) if lastEntitiesCount != appRelatedEntities.count { + Current.Log + .verbose( + "Updating App Entities for \(server.info.name) entities count diff, count: last \(lastEntitiesCount), new \(appRelatedEntities.count)" + ) updateLastUpdate(entitiesCount: appRelatedEntities.count) handle(appRelatedEntities: appRelatedEntities, server: server) } @@ -71,6 +79,10 @@ public final class AppEntitiesModel: AppEntitiesModelProtocol { .fetchAll(db) } if appEntities != cachedEntities { + Current.Log + .verbose( + "Updating App Entities for \(server.info.name), cached entities were different than new entities" + ) try Current.database.write { db in try HAAppEntity.deleteAll(db, ids: cachedEntities.map(\.id)) for entity in appEntities {