1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 07:39:39 +02:00
Maybe/app/controllers/concerns/auto_sync.rb
Zach Gollwitzer e26e5c5aec
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 (#2259)
* Auto sync preference, max limit on account CSV imports

* MaxRowCountExceededError
2025-05-18 15:02:51 -04:00

22 lines
603 B
Ruby

module AutoSync
extend ActiveSupport::Concern
included do
before_action :sync_family, if: :family_needs_auto_sync?
end
private
def sync_family
Current.family.sync_later
end
def family_needs_auto_sync?
return false unless Current.family&.accounts&.active&.any?
return false if (Current.family.last_sync_created_at&.to_date || 1.day.ago) >= Date.current
return false unless Current.family.auto_sync_on_login
Rails.logger.info "Auto-syncing family #{Current.family.id}, last sync was #{Current.family.last_sync_created_at}"
true
end
end