<commit_before>module OwnerStatistic

  def work_count
    self.owner_works.count
  end

  def page_count
    count = Page.where(work_id: self.owner_works.ids).count
  end

  def active_page_count
    inactive = Collection.where(is_active: false).pluck(:id)
    Page.joins(:work => :collection)
      .where(work_id: self.owner_works.ids)
      .where(:'collections.is_active' => true).count
  end
  
  def incomplete_page_count
    Page.where(work_id: self.owner_works.ids)
      .where(status: Page::NEEDS_WORK_STATUSES).count
  end
  
  def needs_review_count(days=nil)
    Page.where(work_id: self.owner_works.ids)
      .where(date_range_clause(days, "edit_started_at"))
      .where(status: Page::STATUS_NEEDS_REVIEW).count
  end
  
  def review_count(days=nil)
    Deed.where(work_id: self.owner_works.ids)
      .where(date_range_clause(days))
      .where(deed_type: DeedType::PAGE_REVIEWED).count
  end

  def owner_subjects
   Article.where(collection_id: self.all_owner_collections.ids)
  end

  def collection_ids
    [self.all_owner_collections.ids]
  end

  def subject_count(days=nil)
    owner_subjects.where(date_range_clause(days, 'created_on')).count
  end

  def mention_count(days=nil)
    PageArticleLink.where(article_id: owner_subjects.ids).where(date_range_clause(days, 'created_on')).count
  end

  def contributor_count(days=nil)
    User.joins(:deeds).where(deeds: {collection_id: collection_ids}).where(date_range_clause(days, 'deeds.created_at')).distinct.count
  end

  def comment_count(days=nil)
    Deed.where(collection_id: collection_ids).where(deed_type: DeedType::NOTE_ADDED).where(date_range_clause(days)).count

  end

  def transcription_count(days=nil)
    Deed.where(collection_id: collection_ids).where(deed_type: DeedType::PAGE_TRANSCRIPTION).where(date_range_clause(days)).count
  end<commit_msg>Don't include collection_joined deeds for contributor count<commit_after>module OwnerStatistic

  def work_count
    self.owner_works.count
  end

  def page_count
    count = Page.where(work_id: self.owner_works.ids).count
  end

  def active_page_count
    inactive = Collection.where(is_active: false).pluck(:id)
    Page.joins(:work => :collection)
      .where(work_id: self.owner_works.ids)
      .where(:'collections.is_active' => true).count
  end
  
  def incomplete_page_count
    Page.where(work_id: self.owner_works.ids)
      .where(status: Page::NEEDS_WORK_STATUSES).count
  end
  
  def needs_review_count(days=nil)
    Page.where(work_id: self.owner_works.ids)
      .where(date_range_clause(days, "edit_started_at"))
      .where(status: Page::STATUS_NEEDS_REVIEW).count
  end
  
  def review_count(days=nil)
    Deed.where(work_id: self.owner_works.ids)
      .where(date_range_clause(days))
      .where(deed_type: DeedType::PAGE_REVIEWED).count
  end

  def owner_subjects
   Article.where(collection_id: self.all_owner_collections.ids)
  end

  def collection_ids
    [self.all_owner_collections.ids]
  end

  def subject_count(days=nil)
    owner_subjects.where(date_range_clause(days, 'created_on')).count
  end

  def mention_count(days=nil)
    PageArticleLink.where(article_id: owner_subjects.ids).where(date_range_clause(days, 'created_on')).count
  end

  def contributor_count(days=nil)
    User.joins(:deeds).where(deeds: {collection_id: collection_ids})
      .where.not(deeds: {deed_type: DeedType::COLLECTION_JOINED})
      .where(date_range_clause(days, 'deeds.created_at')).distinct.count
  end

  def comment_count(days=nil)
    Deed.where(collection_id: collection_ids).where(deed_type: DeedType::NOTE_ADDED).where(date_range_clause(days)).count

  end

  def transcription_count(days=nil)
    Deed.where(collection_id: collection_ids).where(deed_type: DeedType::PAGE_TRANSCRIPTION).where(date_range_clause(days)).count
  end
{'fraction_non_alphanumeric': 0.11064388961892246, 'fraction_numerical': 0.0, 'mean_word_length': 4.792998477929984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4485648', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1342, 'n_words': 183}