<commit_before>class ActivitySerializer < ActiveModel::Serializer
  attributes :uid, :id, :name, :description, :flags, :data, :created_at, :updated_at, :supporting_info, :anonymous_path, :activity_category

  has_one :classification, serializer: ClassificationSerializer
  has_one :topic

  def anonymous_path
    Rails.application.routes.url_helpers.anonymous_activity_sessions_path(activity_id: object.id)
  end

  def activity_category
    ActivityCategory.joins("JOIN activity_category_activities ON activity_categories.id = activity_category_activities.activity_category_id")
    .where("activity_category_activities.activity_id = #{object.id}")
    .limit(1).to_a.first
  end

end<commit_msg>check to ensure new activity has id before running sql<commit_after>class ActivitySerializer < ActiveModel::Serializer
  attributes :uid, :id, :name, :description, :flags, :data, :created_at, :updated_at, :supporting_info, :anonymous_path, :activity_category

  has_one :classification, serializer: ClassificationSerializer
  has_one :topic

  def anonymous_path
    Rails.application.routes.url_helpers.anonymous_activity_sessions_path(activity_id: object.id)
  end

  def activity_category
    if object.id
      ActivityCategory.joins("JOIN activity_category_activities ON activity_categories.id = activity_category_activities.activity_category_id")
      .where("activity_category_activities.activity_id = #{object.id}")
      .limit(1).to_a.first
    end
  end

end
{'fraction_non_alphanumeric': 0.08651226158038147, 'fraction_numerical': 0.0013623978201634877, 'mean_word_length': 6.200980392156863, 'pattern_counts': {'":': 0, '<': 5, '<?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': '915946', 'n_tokens_mistral': 437, 'n_tokens_neox': 432, 'n_words': 87}