1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 05:25:24 +02:00

Auto sync preference, max limit on account CSV imports (#2259)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Auto sync preference, max limit on account CSV imports

* MaxRowCountExceededError
This commit is contained in:
Zach Gollwitzer 2025-05-18 15:02:51 -04:00 committed by GitHub
parent f82f77466a
commit e26e5c5aec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 35 additions and 1 deletions

View file

@ -1,4 +1,6 @@
class Import < ApplicationRecord
MaxRowCountExceededError = Class.new(StandardError)
TYPES = %w[TransactionImport TradeImport AccountImport MintImport].freeze
SIGNAGE_CONVENTIONS = %w[inflows_positive inflows_negative]
SEPARATORS = [ [ "Comma (,)", "," ], [ "Semicolon (;)", ";" ] ].freeze
@ -52,6 +54,7 @@ class Import < ApplicationRecord
end
def publish_later
raise MaxRowCountExceededError if row_count_exceeded?
raise "Import is not publishable" unless publishable?
update! status: :importing
@ -60,6 +63,8 @@ class Import < ApplicationRecord
end
def publish
raise MaxRowCountExceededError if row_count_exceeded?
import!
family.sync_later
@ -220,7 +225,15 @@ class Import < ApplicationRecord
)
end
def max_row_count
10000
end
private
def row_count_exceeded?
rows.count > max_row_count
end
def import!
# no-op, subclasses can implement for customization of algorithm
end