Skip to content

Commit 1ce075c

Browse files
committed
Improve catalog persistence logs to show number of products for a specific site
1 parent b603561 commit 1ce075c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Modules/Sources/Yosemite/Tools/POS/POSCatalogPersistenceService.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ final class POSCatalogPersistenceService: POSCatalogPersistenceServiceProtocol {
6868
DDLogInfo("✅ Catalog persistence complete")
6969

7070
try await grdbManager.databaseConnection.read { db in
71-
let productCount = try PersistedProduct.fetchCount(db)
72-
let productImageCount = try PersistedProductImage.fetchCount(db)
73-
let productAttributeCount = try PersistedProductAttribute.fetchCount(db)
74-
let variationCount = try PersistedProductVariation.fetchCount(db)
75-
let variationImageCount = try PersistedProductVariationImage.fetchCount(db)
76-
let variationAttributeCount = try PersistedProductVariationAttribute.fetchCount(db)
71+
let productCount = try PersistedProduct.filter { $0.siteID == siteID }.fetchCount(db)
72+
let productImageCount = try PersistedProductImage.filter { $0.siteID == siteID }.fetchCount(db)
73+
let productAttributeCount = try PersistedProductAttribute.filter { $0.siteID == siteID }.fetchCount(db)
74+
let variationCount = try PersistedProductVariation.filter { $0.siteID == siteID }.fetchCount(db)
75+
let variationImageCount = try PersistedProductVariationImage.filter { $0.siteID == siteID }.fetchCount(db)
76+
let variationAttributeCount = try PersistedProductVariationAttribute.filter { $0.siteID == siteID }.fetchCount(db)
7777

7878
DDLogInfo("Persisted \(productCount) products, \(productImageCount) product images, " +
7979
"\(productAttributeCount) product attributes, \(variationCount) variations, " +
@@ -140,12 +140,12 @@ final class POSCatalogPersistenceService: POSCatalogPersistenceServiceProtocol {
140140
DDLogInfo("✅ Incremental catalog persistence complete")
141141

142142
try await grdbManager.databaseConnection.read { db in
143-
let productCount = try PersistedProduct.fetchCount(db)
144-
let productImageCount = try PersistedProductImage.fetchCount(db)
145-
let productAttributeCount = try PersistedProductAttribute.fetchCount(db)
146-
let variationCount = try PersistedProductVariation.fetchCount(db)
147-
let variationImageCount = try PersistedProductVariationImage.fetchCount(db)
148-
let variationAttributeCount = try PersistedProductVariationAttribute.fetchCount(db)
143+
let productCount = try PersistedProduct.filter { $0.siteID == siteID }.fetchCount(db)
144+
let productImageCount = try PersistedProductImage.filter { $0.siteID == siteID }.fetchCount(db)
145+
let productAttributeCount = try PersistedProductAttribute.filter { $0.siteID == siteID }.fetchCount(db)
146+
let variationCount = try PersistedProductVariation.filter { $0.siteID == siteID }.fetchCount(db)
147+
let variationImageCount = try PersistedProductVariationImage.filter { $0.siteID == siteID }.fetchCount(db)
148+
let variationAttributeCount = try PersistedProductVariationAttribute.filter { $0.siteID == siteID }.fetchCount(db)
149149

150150
DDLogInfo("Total after incremental update: \(productCount) products, \(productImageCount) product images, " +
151151
"\(productAttributeCount) product attributes, \(variationCount) variations, " +

0 commit comments

Comments
 (0)