Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a088d3e
Add database search query for local catalog products
joshheald Nov 19, 2025
0a479b6
Add local search fetch strategy for POS items
joshheald Nov 19, 2025
ffb0fcc
[Local catalog] Implement local variation fetching from GRDB
joshheald Nov 19, 2025
a3af88b
Wire local search strategy to factory and UI
joshheald Nov 19, 2025
3e82715
[Local catalog] Add explicit local catalog flag to factory
joshheald Nov 19, 2025
9afae0b
[Local catalog] Add analytics tracking for local search
joshheald Nov 19, 2025
9d13321
Add SearchDebounceStrategy enum for configurable search debouncing
joshheald Nov 20, 2025
3637ba0
Add debounceStrategy property to fetch strategy protocols
joshheald Nov 19, 2025
6acb890
Implement strategy-based debouncing in search UI
joshheald Nov 19, 2025
5dae392
Apply simple debouncing strategy to local product search
joshheald Nov 19, 2025
753ca24
Add tests for SearchDebounceStrategy
joshheald Nov 19, 2025
a81e1c7
Fix line length lint violations in SearchDebounceStrategyTests
joshheald Nov 20, 2025
b78f674
Fix SearchDebounceStrategyTests to use existing mocks
joshheald Nov 20, 2025
82a73a0
Fix SQL LIKE escaping to handle special characters (% and _)
joshheald Nov 20, 2025
7cada54
Merge PR1 fix: SQL LIKE escaping for special characters
joshheald Nov 20, 2025
5548479
Merge PR2: includes SQL LIKE escaping fix
joshheald Nov 20, 2025
fe4b43c
Merge PR3: includes SQL LIKE escaping fix
joshheald Nov 20, 2025
ebe7eaa
Merge PR4: includes SQL LIKE escaping fix
joshheald Nov 20, 2025
b528346
Fix GRDBManager access when feature flag is disabled
joshheald Nov 20, 2025
976fff5
Merge PR3: GRDBManager access fix
joshheald Nov 20, 2025
f112338
Merge PR4: GRDBManager access fix
joshheald Nov 20, 2025
60f51e1
Add currentDebounceStrategy to mock controllers
joshheald Nov 20, 2025
d37005d
Fix lint
joshheald Nov 20, 2025
300cd55
Revert marketing version from 23.8 to 23.7
joshheald Nov 20, 2025
adf6e1f
Merge factory-integration branch with version fix
joshheald Nov 20, 2025
3aa198b
Merge analytics branch with version fix
joshheald Nov 20, 2025
0a668f1
Add loadingDelayThreshold to smart debounce strategy
joshheald Nov 20, 2025
9656089
Fix loading indicators not showing on first remote search
joshheald Nov 20, 2025
de5a625
Remove unnecessary comment
joshheald Nov 20, 2025
42335af
Fix test build
joshheald Nov 20, 2025
5e4e396
Fix periphery issues
joshheald Nov 20, 2025
2dc3ff6
Rename debounceStrategy to currentDebounceStrategy for clarity
joshheald Nov 20, 2025
63c3b71
Fix Swift6 warning
joshheald Nov 21, 2025
5e690fb
Revert "Revert marketing version from 23.8 to 23.7"
joshheald Nov 21, 2025
9045166
Revert changes to marketing version
joshheald Nov 21, 2025
46b7571
Update test to have an excluded product
joshheald Nov 21, 2025
d6d0723
Merge branch 'trunk' into woomob-1112-woo-poslocal-catalog-implement-…
joshheald Nov 21, 2025
6e046d5
Fix test compilation after trunk merge
joshheald Nov 21, 2025
182184a
Merge branch 'woomob-1112-woo-poslocal-catalog-implement-product-sear…
joshheald Nov 21, 2025
bc2a8ca
Merge branch 'woomob-1112-woo-poslocal-catalog-local-search-strategy'…
joshheald Nov 21, 2025
61837ab
Merge branch 'woomob-1112-woo-poslocal-catalog-factory-integration' i…
joshheald Nov 21, 2025
59f976f
Merge branch 'woomob-1112-woo-poslocal-catalog-analytics' into woomob…
joshheald Nov 21, 2025
eb8be6e
Fix test compilation after trunk merge - add statusKey parameter
joshheald Nov 21, 2025
3945526
Merge branch 'woomob-1112-woo-poslocal-catalog-local-search-strategy'…
joshheald Nov 21, 2025
d1bf02e
Merge branch 'woomob-1112-woo-poslocal-catalog-factory-integration' i…
joshheald Nov 21, 2025
bf2d785
Merge branch 'woomob-1112-woo-poslocal-catalog-analytics' into woomob…
joshheald Nov 21, 2025
992afaf
Escape the escape!
joshheald Nov 21, 2025
37b4e98
Don’t show intermittent cancellation errors in search
joshheald Nov 21, 2025
6d45ae6
Remove unnecessary `await` call
joshheald Nov 24, 2025
094c919
Use a default duration for smart debounce
joshheald Nov 24, 2025
6efe96f
Split up debounce logic
joshheald Nov 24, 2025
851119c
[Local catalog] Add configurable search debounce strategies (#16377)
joshheald Nov 24, 2025
5b71a8e
[Local catalog] Add analytics tracking for local search (#16376)
joshheald Nov 24, 2025
9d31a95
[Local catalog] Wire local search strategy to factory and UI (#16375)
joshheald Nov 24, 2025
769a65e
[Local catalog] Implement local search strategy with GRDB (#16374)
joshheald Nov 24, 2025
a153e87
Merge branch 'trunk' into woomob-1112-woo-poslocal-catalog-implement-…
joshheald Nov 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Modules/Sources/Storage/GRDB/Model/PersistedProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,36 @@ public extension PersistedProduct {
.filter(Columns.siteID == siteID)
.filter(Columns.globalUniqueID == globalUniqueID)
}

/// Searches for POS-supported products by search term using LIKE query
/// - Parameters:
/// - siteID: The site ID
/// - searchTerm: The search term to match against product name, SKU, and global unique ID
/// - Returns: A query request that matches products containing the search term, ordered by name
static func posProductSearch(siteID: Int64, searchTerm: String) -> QueryInterfaceRequest<PersistedProduct> {
let escapedTerm = escapeSQLLikePattern(searchTerm)
let likePattern = "%\(escapedTerm)%"

return PersistedProduct
.filter(Columns.siteID == siteID)
.filter([ProductType.simple.rawValue, ProductType.variable.rawValue].contains(Columns.productTypeKey))
.filter(Columns.downloadable == false)
.filter(
Columns.name.like(likePattern, escape: "\\") ||
Columns.sku.like(likePattern, escape: "\\") ||
Columns.globalUniqueID.like(likePattern, escape: "\\")
)
.order(Columns.name.collating(.localizedCaseInsensitiveCompare))
}

/// Escapes special SQL LIKE pattern characters (% and _) in a search term
/// - Parameter pattern: The user-provided search term
/// - Returns: An escaped pattern safe for use in LIKE queries
private static func escapeSQLLikePattern(_ pattern: String) -> String {
pattern
.replacingOccurrences(of: "%", with: "\\%")
.replacingOccurrences(of: "_", with: "\\_")
Comment on lines +160 to +161
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take it with a grain of salt since I'm not versed in this. The LLM shares that for completeness we can also escape \, but since GRDB passes the escape character explicitly and most product searches won’t include backslashes, the current implementation adequate.

If so, the suggestion would be to add .replacingOccurrences(of: "\\", with: "\\\\") as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, interesting. I'll check this one, and see what the behaviour is if you search with slashes...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right, \ in the search term was treated as an escape character. Fixed in 992afaf

}
}

// periphery:ignore - TODO: remove ignore when populating database
Expand Down
Loading