mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
fix: Lunchflow pending transaction duplicates, missing from search and filter (#859)
* fix: lunchflow parity with simplefin/plaid pending behaviour * fix: don't suggest duplicate if both entries are pending * refactor: reuse the same external_id for re-synced pending transactions * chore: replace illogical duplicate collision test with multiple sync test * fix: prevent duplicates when users edit pending lunchflow transactions * chore: add test for preventing duplicates when users edit pending lunchflow transactions * fix: normalise extra hash keys for pending detection
This commit is contained in:
@@ -42,6 +42,7 @@ class Entry < ApplicationRecord
|
||||
.where(<<~SQL.squish)
|
||||
(transactions.extra -> 'simplefin' ->> 'pending')::boolean = true
|
||||
OR (transactions.extra -> 'plaid' ->> 'pending')::boolean = true
|
||||
OR (transactions.extra -> 'lunchflow' ->> 'pending')::boolean = true
|
||||
SQL
|
||||
}
|
||||
|
||||
@@ -56,6 +57,7 @@ class Entry < ApplicationRecord
|
||||
AND (
|
||||
(t.extra -> 'simplefin' ->> 'pending')::boolean = true
|
||||
OR (t.extra -> 'plaid' ->> 'pending')::boolean = true
|
||||
OR (t.extra -> 'lunchflow' ->> 'pending')::boolean = true
|
||||
)
|
||||
)
|
||||
SQL
|
||||
@@ -118,6 +120,7 @@ class Entry < ApplicationRecord
|
||||
.where(<<~SQL.squish)
|
||||
(transactions.extra -> 'simplefin' ->> 'pending')::boolean IS NOT TRUE
|
||||
AND (transactions.extra -> 'plaid' ->> 'pending')::boolean IS NOT TRUE
|
||||
AND (transactions.extra -> 'lunchflow' ->> 'pending')::boolean IS NOT TRUE
|
||||
SQL
|
||||
.limit(2) # Only need to know if 0, 1, or 2+ candidates
|
||||
.to_a # Load limited records to avoid COUNT(*) on .size
|
||||
@@ -164,6 +167,7 @@ class Entry < ApplicationRecord
|
||||
.where(<<~SQL.squish)
|
||||
(transactions.extra -> 'simplefin' ->> 'pending')::boolean IS NOT TRUE
|
||||
AND (transactions.extra -> 'plaid' ->> 'pending')::boolean IS NOT TRUE
|
||||
AND (transactions.extra -> 'lunchflow' ->> 'pending')::boolean IS NOT TRUE
|
||||
SQL
|
||||
|
||||
# Match by name similarity (first 3 words)
|
||||
|
||||
Reference in New Issue
Block a user