mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-18 02:20:37 -05:00
CustomerToken.purge_expired deletes share links that have expired or whose issue was deleted. It runs whenever a new link is made, so they don't pile up, and from rake redmine_qbo:purge_customer_tokens for a manual or scheduled run. Expired links were only ignored before. Also drops Issue's belongs_to :customer_token: issues have no such column, so the association could only raise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.9 KiB
Ruby
30 lines
1.9 KiB
Ruby
#The MIT License (MIT)
|
|
#
|
|
#Copyright (c) 2026 rick barrette
|
|
#
|
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
#
|
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
#
|
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
namespace :redmine_qbo do
|
|
desc 'Relate all issues created from the same QBO estimate to each other (one-time catch-up; safe to re-run)'
|
|
task relate_estimate_issues: :environment do
|
|
total = 0
|
|
estimates = QboEstimateLineIssue.distinct.pluck(:estimate_id)
|
|
|
|
estimates.each do |estimate_id|
|
|
issues = QboEstimateLineIssue.where(estimate_id: estimate_id).includes(:issue).filter_map(&:issue)
|
|
total += RedmineQboBilling::EstimateIssueBuilder.relate_all(issues)
|
|
end
|
|
|
|
puts "Checked #{estimates.size} estimate(s), created #{total} relation(s)."
|
|
end
|
|
|
|
desc "Delete customer share links that have expired or whose issue was deleted (also done whenever a link is made)"
|
|
task purge_customer_tokens: :environment do
|
|
puts "Deleted #{CustomerToken.purge_expired} customer share link(s)."
|
|
end
|
|
end
|