<commit_before>namespace :publishing_api do
  desc "populate publishing api with lead organisations"
  task publish_lead_organisations: :environment do
    Policy.find_each do |policy|

      links_payload = {
        links: {
          organisations: policy.organisation_content_ids
        }
      }

      lead_organisation = policy.organisation_content_ids.first

      if lead_organisation
        links_payload[:links][:lead_organisations] = [ lead_organisation ]
      end

      puts "Publishing '#{policy.name}' orgs to publishing-api"
      Services.publishing_api.put_links(policy.content_id, links_payload)
    end
  end
end<commit_msg>Fetches policy organisations from database<commit_after>namespace :publishing_api do
  desc "populate publishing api with lead organisations"
  task publish_lead_organisations: :environment do
    Policy.find_each do |policy|

      organisations_from_db = policy[:organisation_content_ids]

      links_payload = {
        links: {
          organisations: organisations_from_db
        }
      }

      lead_organisation = organisations_from_db.first

      if lead_organisation
        links_payload[:links][:lead_organisations] = [ lead_organisation ]
      end

      puts "Publishing '#{policy.name}' orgs to publishing-api"
      Services.publishing_api.put_links(policy.content_id, links_payload)
    end
  end
end
{'fraction_non_alphanumeric': 0.06861313868613139, 'fraction_numerical': 0.0, 'mean_word_length': 3.380191693290735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5925316', 'n_tokens_mistral': 395, 'n_tokens_neox': 380, 'n_words': 83}