<commit_before>json.array!(@trainings) do |training|
  json.id training.id
  json.name training.name
  json.description training.description
  json.machine_ids training.machine_ids
  json.availabilities training.availabilities do |a|
    json.id a.id
    json.start_at a.start_at.iso8601
    json.end_at a.end_at.iso8601
    json.reservation_users a.slots.map do |slot|
      json.id slot.reservation.user.id
      json.full_name slot.reservation.user.profile.full_name
      json.is_valid slot.reservation.user.trainings.include?(training)
    end
  end if attribute_requested?(@requested_attributes, 'availabilities')
  json.nb_total_places training.nb_total_places

  json.plan_ids training.plan_ids if current_user and current_user.is_admin?
end<commit_msg>cache training json<commit_after>role = (current_user and current_user.is_admin?) ? 'admin' : 'user'

json.cache! [@trainings, role] do
  json.array!(@trainings) do |training|
    json.id training.id
    json.name training.name
    json.description training.description
    json.machine_ids training.machine_ids
    json.nb_total_places training.nb_total_places

    json.plan_ids training.plan_ids if role === 'admin'
  end
end
{'fraction_non_alphanumeric': 0.09167367535744322, 'fraction_numerical': 0.00672834314550042, 'mean_word_length': 4.384615384615385, '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': '2547447', 'n_tokens_mistral': 396, 'n_tokens_neox': 385, 'n_words': 76}