<commit_before># encoding: utf-8

class MaintainersController < ApplicationController
  # helper_method :sort_column, :sort_direction

  def show
    @branch = Branch.where(:name => params[:branch], :vendor => 'ALT Linux').first
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    @acls = Acl.where(:maintainer_id => @maintainer, :branch_id => @branch)
  end

  def srpms
    @branch = Branch.where(:name => params[:branch], :vendor => 'ALT Linux').first
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    # @acls = Acl.where(:maintainer_id => @maintainer, :branch_id => @branch).includes(:srpm => [:repocop_patch]).order(sort_column + ' ' + sort_direction) #.order('LOWER(srpms.name)')
    @acls = Acl.where(:maintainer_id => @maintainer, :branch_id => @branch).includes(:srpm => [:repocop_patch]).order('LOWER(srpms.name)')
  end

#  def acls
#    @branch = Branch.where(:name => params[:branch], :vendor => "ALT Linux").first
#    @maintainer = Maintainer.first :conditions => {
#                                     :login => params[:id].downcase,
#                                     :team => false }
#    @acls = Acl.all :conditions => {
#                      :login => params[:login],
#                      :branch_id => @branch.id }
#    if @maintainer == nil
#      render :status => 404, :action => "nosuchmaintainer"
#    end
#  end

  def gear
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    @gears = Gear.where(:maintainer_id => @maintainer).order('LOWER(repo)')
  end

  def bugs
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    @bugs = Bug.where(:assigned_to => "#{<EMAIL>",
                      :product => 'Sisyphus',
                      :bug_status => ['NEW', 'ASSIGNED', 'VERIFIED', 'REOPENED']).order('bug_id DESC')
    @allbugs = Bug.where(:assigned_to => "#{<EMAIL>",
                         :product => 'Sisyphus').order('bug_id DESC')
  end

  def allbugs
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    @bugs = Bug.where(:assigned_to => "#{<EMAIL>",
                      :product => 'Sisyphus',
                      :bug_status => ['NEW', 'ASSIGNED', 'VERIFIED', 'REOPENED']).order('bug_id DESC')
    @allbugs = Bug.where(:assigned_to => "#{<EMAIL>",
                         :product => 'Sisyphus').order('bug_id DESC')
  end

  def ftbfs
    @branch = Branch.where(:name => params[:branch], :vendor => 'ALT Linux').first
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    @ftbfs = Ftbfs.where(:branch_id => @branch, :maintainer_id => @maintainer)
  end

  def repocop
    @branch = Branch.where(:vendor => 'ALT Linux', :name => 'Sisyphus').first
    @maintainer = Maintainer.where(:login => params[:id].downcase, :team => false).includes(:srpms).order('LOWER(srpms.name)').first
    render(:status => 404, :action => 'nosuchmaintainer') and return if @maintainer == nil
    @srpms = @maintainer.srpms.where(:branch_id => @branch).includes(:repocops)
  end

  # private
  # <commit_msg>Convert to new hash syntax<commit_after># encoding: utf-8

class MaintainersController < ApplicationController
  # helper_method :sort_column, :sort_direction

  def show
    @branch = Branch.where(name: params[:branch], vendor: 'ALT Linux').first
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    @acls = Acl.where(maintainer_id: @maintainer, branch_id: @branch)
  end

  def srpms
    @branch = Branch.where(name: params[:branch], vendor: 'ALT Linux').first
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    # @acls = Acl.where(:maintainer_id => @maintainer, :branch_id => @branch).includes(:srpm => [:repocop_patch]).order(sort_column + ' ' + sort_direction) #.order('LOWER(srpms.name)')
    @acls = Acl.where(maintainer_id: @maintainer, branch_id: @branch).includes(:srpm => [:repocop_patch]).order('LOWER(srpms.name)')
  end

#  def acls
#    @branch = Branch.where(:name => params[:branch], :vendor => "ALT Linux").first
#    @maintainer = Maintainer.first :conditions => {
#                                     :login => params[:id].downcase,
#                                     :team => false }
#    @acls = Acl.all :conditions => {
#                      :login => params[:login],
#                      :branch_id => @branch.id }
#    if @maintainer == nil
#      render :status => 404, :action => "nosuchmaintainer"
#    end
#  end

  def gear
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    @gears = Gear.where(maintainer_id: @maintainer).order('LOWER(repo)')
  end

  def bugs
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    @bugs = Bug.where(assigned_to: "#{<EMAIL>",
                      product: 'Sisyphus',
                      bug_status: ['NEW', 'ASSIGNED', 'VERIFIED', 'REOPENED']).order('bug_id DESC')
    @allbugs = Bug.where(assigned_to: "#{<EMAIL>",
                         product: 'Sisyphus').order('bug_id DESC')
  end

  def allbugs
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    @bugs = Bug.where(assigned_to: "#{<EMAIL>",
                      product: 'Sisyphus',
                      bug_status: ['NEW', 'ASSIGNED', 'VERIFIED', 'REOPENED']).order('bug_id DESC')
    @allbugs = Bug.where(assigned_to: "#{<EMAIL>",
                         product: 'Sisyphus').order('bug_id DESC')
  end

  def ftbfs
    @branch = Branch.where(name: params[:branch], vendor: 'ALT Linux').first
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    @ftbfs = Ftbfs.where(branch_id: @branch, maintainer_id: @maintainer)
  end

  def repocop
    @branch = Branch.where(vendor: 'ALT Linux', name: 'Sisyphus').first
    @maintainer = Maintainer.where(login: params[:id].downcase, team: false).includes(:srpms).order('LOWER(srpms.name)').first
    render(status: 404, action: 'nosuchmaintainer') and return if @maintainer == nil
    @srpms = @maintainer.srpms.where(branch_id: @branch).includes(:repocops)
  end

  # private
  # 
{'fraction_non_alphanumeric': 0.16541147473640969, 'fraction_numerical': 0.006846501437765302, 'mean_word_length': 3.334718100890208, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '660788', 'n_tokens_mistral': 2492, 'n_tokens_neox': 2312, 'n_words': 502}