<commit_before>require 'shipmate/ipa_parser'

class IosAppsController < ApplicationController

  include AppListingModule

  APP_ASSET_INDEX = 0
  ICON_ASSET_INDEX = 1

  attr_accessor :ios_dir

  before_action do
    @device_type = :iphone if browser.iphone? or browser.ipod?
    @device_type = :ipad if browser.ipad? 
    @device_type ||= :desktop
  end

  def initialize
    @ios_dir = Shipmate::Application.config.ios_dir
    FileUtils.mkdir_p(@ios_dir)
    super
  end

  def list_app_releases
    @app_name = params[:app_name]
    app_builds = self.app_builds(@app_name, @ios_dir, IOS_APP_TYPE)

    @most_recent_build_hash = most_recent_build_by_release(app_builds)
    @app_releases = VersionSorter.rsort(@most_recent_build_hash.keys)
    @mobileprovision = mobileprovision_file_url(@app_name)
  end

  def mobileprovision_file_url(app_name)
    mobileprovision_file = Dir.glob(@ios_dir.join(app_name,"*.mobileprovision")).first
    if mobileprovision_file
      "#{request.base_url}/apps/ios/#{app_name}/#{mobileprovision_file.split('/').last}"
    else
      nil
    end
  end

  def list_app_builds<commit_msg>Duplicate and unexecuted code<commit_after>require 'shipmate/ipa_parser'

class IosAppsController < ApplicationController

  include AppListingModule

  APP_ASSET_INDEX = 0
  ICON_ASSET_INDEX = 1

  attr_accessor :ios_dir

  def initialize
    @ios_dir = Shipmate::Application.config.ios_dir
    FileUtils.mkdir_p(@ios_dir)
    super
  end

  def list_app_releases
    @app_name = params[:app_name]
    app_builds = self.app_builds(@app_name, @ios_dir, IOS_APP_TYPE)

    @most_recent_build_hash = most_recent_build_by_release(app_builds)
    @app_releases = VersionSorter.rsort(@most_recent_build_hash.keys)
    @mobileprovision = mobileprovision_file_url(@app_name)
  end

  def mobileprovision_file_url(app_name)
    mobileprovision_file = Dir.glob(@ios_dir.join(app_name,"*.mobileprovision")).first
    if mobileprovision_file
      "#{request.base_url}/apps/ios/#{app_name}/#{mobileprovision_file.split('/').last}"
    else
      nil
    end
  end

  def list_app_builds
{'fraction_non_alphanumeric': 0.09208015267175572, 'fraction_numerical': 0.0019083969465648854, 'mean_word_length': 4.562334217506631, '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': '6186314', 'n_tokens_mistral': 772, 'n_tokens_neox': 735, 'n_words': 113}