<commit_before>class ClientOccupationReport < Report
  attr_accessor :from_date, :to_date, :branch, :center, :branch_id, :center_id, :staff_member_id

  def initialize(params, dates, user)
    @from_date = (dates and dates[:from_date]) ? dates[:from_date] : Date.today - 30
    @to_date   = (dates and dates[:to_date]) ? dates[:to_date] : Date.today  
    @name   = "Report from #{@from_date} to #{@to_date}"
    get_parameters(params, user)
  end
  
  def name
    "Report from #{@from_date} to #{@to_date}"
  end
  
  def self.name
    "Client occupation report"
  end
  
  def generate
    repository.adapter.query(%Q{SELECT o.name occupation, count(clients.id) clients, count(loans.id) loans, SUM(loans.amount) amount
                                FROM loans, clients
                                LEFT OUTER JOIN occupations o ON o.id=clients.occupation_id
                                WHERE clients.id=loans.client_id AND clients.id IN (SELECT id FROM clients WHERE date_joined BETWEEN '#{@from_date.strftime('%Y-%m-%d')}' AND '#{@to_date.strftime('%Y-%m-%d')}')
                                      AND loans.deleted_at is NULL AND loans.disbursal_date is NOT NULL
                                GROUP BY clients.occupation_id;})
  end
end
<commit_msg>Re-Added branch, center and staff member filters<commit_after>class ClientOccupationReport < Report
  attr_accessor :from_date, :to_date, :branch, :center, :branch_id, :center_id, :staff_member_id

  def initialize(params, dates, user)
    @from_date = (dates and dates[:from_date]) ? dates[:from_date] : Date.today - 30
    @to_date   = (dates and dates[:to_date]) ? dates[:to_date] : Date.today  
    @name   = "Report from #{@from_date} to #{@to_date}"
    get_parameters(params, user)
  end
  
  def name
    "Report from #{@from_date} to #{@to_date}"
  end
  
  def self.name
    "Client occupation report"
  end
  
  def generate
    repository.adapter.query(%Q{SELECT o.name occupation, count(clients.id) clients, count(loans.id) loans, SUM(loans.amount) amount
                                FROM loans, clients
                                LEFT OUTER JOIN occupations o ON o.id=clients.occupation_id
                                WHERE clients.id=loans.client_id AND clients.id IN (SELECT id FROM clients 
                                                                                    WHERE date_joined BETWEEN '#{@from_date.strftime('%Y-%m-%d')}' 
                                                                                          AND '#{@to_date.strftime('%Y-%m-%d')}'
                                                                                          AND clients.center_id in (#{@center.map{|c| c.id}.join(', ')}))
                                      AND loans.deleted_at is NULL AND loans.disbursal_date is NOT NULL
                                GROUP BY clients.occupation_id;})
  end
end

{'fraction_non_alphanumeric': 0.10517241379310345, 'fraction_numerical': 0.001379310344827586, 'mean_word_length': 1.8779761904761905, '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': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1553031', 'n_tokens_mistral': 861, 'n_tokens_neox': 824, 'n_words': 213}