Skip to content

Commit

Permalink
Log org id and update rescue blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ellohez committed Nov 21, 2024
1 parent 26a3320 commit e56afad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/tasks/access_and_permissions.rake
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ namespace :permissions do
message = "Access permission successfully assigned to document with ID - #{document.id}"
end
args[:log_file] ? args[:log_file].puts(message) : puts(message)
rescue StandardError => e
rescue Mongoid::Errors::DocumentNotFound => e
error_message = "An error occurred while processing document ID #{args[:document_content_id]}: #{e.message}"
args[:log_file] ? args[:log_file].puts(error_message) : puts(error_message)
end

desc "Bulk process access permissions from CSV of URLs - See doc"
desc "Bulk process access permissions from CSV of URLs"
task :bulk_process_access_flags, %i[csv_filename organisation_id] => :environment do |_, args|
log_file = File.new("/tmp/permissions_rake_log.txt", "w")
log_file = File.open("/tmp/permissions_rake_log.txt", "w")
log_file.puts("Adding access permissions for Org ID - #{args[:organisation_id]}")

begin
CSV.foreach(args[:csv_filename], headers: true) do |row|
Expand All @@ -40,8 +41,8 @@ namespace :permissions do

Rake::Task["permissions:add_organisation_access"].reenable
Rake::Task["permissions:add_organisation_access"].invoke(document.id, args[:organisation_id], log_file)
rescue Mongoid::Errors::DocumentNotFound => e
log_file.puts "--- Document not found error ---"
rescue StandardError => e
log_file.puts "--- Error occurred ---"
log_file.puts e.detailed_message
log_file.puts "------"
end
Expand Down
21 changes: 21 additions & 0 deletions lib/tasks/rake_test_short.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Who's checking?,url,title,documentType,Organisation tags,Verified,Any difficulties or controversies over the primary tag being the sole editor? Please explain,More than one owner?,EC,Filter
Anna,https://www.gov.uk/log-in-register-hmrc-online-services,HMRC online services: sign in or set up an account,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/child-benefit-16-19,Child Benefit when your child turns 16,answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/personal-tax-account,Personal tax account: sign in or set up,answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/estimate-income-tax,Estimate your Income Tax for the current year,transaction,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/contact-hmrc,Contact HMRC,answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/log-in-file-self-assessment-tax-return,File your Self Assessment tax return online,answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/tax-free-childcare,Tax-Free Childcare,answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/income-tax-rates,Income Tax rates and Personal Allowances,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/self-assessment-tax-returns,Self Assessment tax returns,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/check-income-tax-current-year,Check your Income Tax for the current year,answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/check-national-insurance-record,Check your National Insurance record,transaction,"“HM Revenue & Customs”, “Department for Work and Pensions”",TRUE,Unsure if DWP have ever had input into this page?,MAYBE,"JH: Looks fine to include, appears to only be HMRC who update it",Y
Anna,https://www.gov.uk/child-benefit,Child Benefit,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/manage-your-tax-credits,Manage your tax credits,transaction,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/pay-self-assessment-tax-bill,Pay your Self Assessment tax bill,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/check-if-you-need-tax-return,Check if you need to send a Self Assessment tax return,simple_smart_answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/claim-tax-refund,How to claim a tax refund,simple_smart_answer,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/register-for-self-assessment,Register for Self Assessment,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/tax-codes,Tax codes,guide,HM Revenue & Customs,TRUE,,,,
Anna,https://www.gov.uk/lost-national-insurance-number,Find a lost National Insurance number,answer,"“HM Revenue & Customs”, “Department for Work and Pensions”",TRUE,,,,
Anna,https://www.gov.uk/check-uk-vat-number,Check a UK VAT number,transaction,HM Revenue & Customs,TRUE,,,,

0 comments on commit e56afad

Please sign in to comment.