Best Active_mocker_ruby code snippet using Sort.limit
001_setup.rb
Source:001_setup.rb
...22 class Permission < ActiveRecord::Base; end23 def self.up24 create_table "attachments", :force => true do |t|25 t.column "container_id", :integer, :default => 0, :null => false26 t.column "container_type", :string, :limit => 30, :default => "", :null => false27 t.column "filename", :string, :default => "", :null => false28 t.column "disk_filename", :string, :default => "", :null => false29 t.column "filesize", :integer, :default => 0, :null => false30 t.column "content_type", :string, :limit => 60, :default => ""31 t.column "digest", :string, :limit => 40, :default => "", :null => false32 t.column "downloads", :integer, :default => 0, :null => false33 t.column "author_id", :integer, :default => 0, :null => false34 t.column "created_on", :timestamp35 end36 create_table "auth_sources", :force => true do |t|37 t.column "type", :string, :limit => 30, :default => "", :null => false38 t.column "name", :string, :limit => 60, :default => "", :null => false39 t.column "host", :string, :limit => 6040 t.column "port", :integer41 t.column "account", :string, :limit => 6042 t.column "account_password", :string, :limit => 6043 t.column "base_dn", :string, :limit => 25544 t.column "attr_login", :string, :limit => 3045 t.column "attr_firstname", :string, :limit => 3046 t.column "attr_lastname", :string, :limit => 3047 t.column "attr_mail", :string, :limit => 3048 t.column "onthefly_register", :boolean, :default => false, :null => false49 end50 create_table "custom_fields", :force => true do |t|51 t.column "type", :string, :limit => 30, :default => "", :null => false52 t.column "name", :string, :limit => 30, :default => "", :null => false53 t.column "field_format", :string, :limit => 30, :default => "", :null => false54 t.column "possible_values", :text55 t.column "regexp", :string, :default => ""56 t.column "min_length", :integer, :default => 0, :null => false57 t.column "max_length", :integer, :default => 0, :null => false58 t.column "is_required", :boolean, :default => false, :null => false59 t.column "is_for_all", :boolean, :default => false, :null => false60 end61 create_table "custom_fields_projects", :id => false, :force => true do |t|62 t.column "custom_field_id", :integer, :default => 0, :null => false63 t.column "project_id", :integer, :default => 0, :null => false64 end65 create_table "custom_fields_trackers", :id => false, :force => true do |t|66 t.column "custom_field_id", :integer, :default => 0, :null => false67 t.column "tracker_id", :integer, :default => 0, :null => false68 end69 create_table "custom_values", :force => true do |t|70 t.column "customized_type", :string, :limit => 30, :default => "", :null => false71 t.column "customized_id", :integer, :default => 0, :null => false72 t.column "custom_field_id", :integer, :default => 0, :null => false73 t.column "value", :text74 end75 create_table "documents", :force => true do |t|76 t.column "project_id", :integer, :default => 0, :null => false77 t.column "category_id", :integer, :default => 0, :null => false78 t.column "title", :string, :limit => 60, :default => "", :null => false79 t.column "description", :text80 t.column "created_on", :timestamp81 end82 add_index "documents", ["project_id"], :name => "documents_project_id"83 create_table "enumerations", :force => true do |t|84 t.column "opt", :string, :limit => 4, :default => "", :null => false85 t.column "name", :string, :limit => 30, :default => "", :null => false86 end87 create_table "issue_categories", :force => true do |t|88 t.column "project_id", :integer, :default => 0, :null => false89 t.column "name", :string, :limit => 30, :default => "", :null => false90 end91 add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id"92 create_table "issue_histories", :force => true do |t|93 t.column "issue_id", :integer, :default => 0, :null => false94 t.column "status_id", :integer, :default => 0, :null => false95 t.column "author_id", :integer, :default => 0, :null => false96 t.column "notes", :text97 t.column "created_on", :timestamp98 end99 add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id"100 create_table "issue_statuses", :force => true do |t|101 t.column "name", :string, :limit => 30, :default => "", :null => false102 t.column "is_closed", :boolean, :default => false, :null => false103 t.column "is_default", :boolean, :default => false, :null => false104 t.column "html_color", :string, :limit => 6, :default => "FFFFFF", :null => false105 end106 create_table "issues", :force => true do |t|107 t.column "tracker_id", :integer, :default => 0, :null => false108 t.column "project_id", :integer, :default => 0, :null => false109 t.column "subject", :string, :default => "", :null => false110 t.column "description", :text111 t.column "due_date", :date112 t.column "category_id", :integer113 t.column "status_id", :integer, :default => 0, :null => false114 t.column "assigned_to_id", :integer115 t.column "priority_id", :integer, :default => 0, :null => false116 t.column "fixed_version_id", :integer117 t.column "author_id", :integer, :default => 0, :null => false118 t.column "lock_version", :integer, :default => 0, :null => false119 t.column "created_on", :timestamp120 t.column "updated_on", :timestamp121 end122 add_index "issues", ["project_id"], :name => "issues_project_id"123 create_table "members", :force => true do |t|124 t.column "user_id", :integer, :default => 0, :null => false125 t.column "project_id", :integer, :default => 0, :null => false126 t.column "role_id", :integer, :default => 0, :null => false127 t.column "created_on", :timestamp128 end129 create_table "news", :force => true do |t|130 t.column "project_id", :integer131 t.column "title", :string, :limit => 60, :default => "", :null => false132 t.column "summary", :string, :limit => 255, :default => ""133 t.column "description", :text134 t.column "author_id", :integer, :default => 0, :null => false135 t.column "created_on", :timestamp136 end137 add_index "news", ["project_id"], :name => "news_project_id"138 create_table "permissions", :force => true do |t|139 t.column "controller", :string, :limit => 30, :default => "", :null => false140 t.column "action", :string, :limit => 30, :default => "", :null => false141 t.column "description", :string, :limit => 60, :default => "", :null => false142 t.column "is_public", :boolean, :default => false, :null => false143 t.column "sort", :integer, :default => 0, :null => false144 t.column "mail_option", :boolean, :default => false, :null => false145 t.column "mail_enabled", :boolean, :default => false, :null => false146 end147 create_table "permissions_roles", :id => false, :force => true do |t|148 t.column "permission_id", :integer, :default => 0, :null => false149 t.column "role_id", :integer, :default => 0, :null => false150 end151 add_index "permissions_roles", ["role_id"], :name => "permissions_roles_role_id"152 create_table "projects", :force => true do |t|153 t.column "name", :string, :limit => 30, :default => "", :null => false154 t.column "description", :string, :default => "", :null => false155 t.column "homepage", :string, :limit => 60, :default => ""156 t.column "is_public", :boolean, :default => true, :null => false157 t.column "parent_id", :integer158 t.column "projects_count", :integer, :default => 0159 t.column "created_on", :timestamp160 t.column "updated_on", :timestamp161 end162 create_table "roles", :force => true do |t|163 t.column "name", :string, :limit => 30, :default => "", :null => false164 end165 create_table "tokens", :force => true do |t|166 t.column "user_id", :integer, :default => 0, :null => false167 t.column "action", :string, :limit => 30, :default => "", :null => false168 t.column "value", :string, :limit => 40, :default => "", :null => false169 t.column "created_on", :datetime, :null => false170 end171 create_table "trackers", :force => true do |t|172 t.column "name", :string, :limit => 30, :default => "", :null => false173 t.column "is_in_chlog", :boolean, :default => false, :null => false174 end175 create_table "users", :force => true do |t|176 t.column "login", :string, :limit => 30, :default => "", :null => false177 t.column "hashed_password", :string, :limit => 40, :default => "", :null => false178 t.column "firstname", :string, :limit => 30, :default => "", :null => false179 t.column "lastname", :string, :limit => 30, :default => "", :null => false180 t.column "mail", :string, :limit => 60, :default => "", :null => false181 t.column "mail_notification", :boolean, :default => true, :null => false182 t.column "admin", :boolean, :default => false, :null => false183 t.column "status", :integer, :default => 1, :null => false184 t.column "last_login_on", :datetime185 t.column "language", :string, :limit => 2, :default => ""186 t.column "auth_source_id", :integer187 t.column "created_on", :timestamp188 t.column "updated_on", :timestamp189 end190 create_table "versions", :force => true do |t|191 t.column "project_id", :integer, :default => 0, :null => false192 t.column "name", :string, :limit => 30, :default => "", :null => false193 t.column "description", :string, :default => ""194 t.column "effective_date", :date195 t.column "created_on", :timestamp196 t.column "updated_on", :timestamp197 end198 add_index "versions", ["project_id"], :name => "versions_project_id"199 create_table "workflows", :force => true do |t|200 t.column "tracker_id", :integer, :default => 0, :null => false201 t.column "old_status_id", :integer, :default => 0, :null => false202 t.column "new_status_id", :integer, :default => 0, :null => false203 t.column "role_id", :integer, :default => 0, :null => false204 end205 # project206 Permission.create :controller => "projects", :action => "show", :description => "label_overview", :sort => 100, :is_public => true...
games_controller.rb
Source:games_controller.rb
1class GamesController < ApplicationController2 before_action :authenticate_admin!, except: [:index, :index_2, :show]3 def index4 @limit = 205 @page = 16 @search = ""7 if params[:search]8 @search = params[:search]9 end10 if params[:page]11 @page = params[:page]12 end13 @sort_attribute = params[:sort_attribute]14 @sort_attribute_2 = params[:sort_attribute_2]15 @filter = params[:filter]16 if !@search.empty?17 @games = Game.where("name ILIKE ?", "%#{params[:search]}%").order(:name).page(@page).per(@limit)18 @games_next = Game.where("name ILIKE ?", "%#{params[:search]}%").order(:name).page(@page.to_i + 1).per(@limit)19 @games_next_2 = Game.where("name ILIKE ?", "%#{params[:search]}%").order(:name).page(@page.to_i + 2).per(@limit)20 elsif @sort_attribute == "platform"21 if @filter == "name_up"22 @games = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order(:name).page(@page).per(@limit)23 @games_next = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order(:name).page(@page.to_i + 1).per(@limit)24 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order(:name).page(@page.to_i + 2).per(@limit)25 elsif @filter == "name_down"26 @games = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order(name: :desc).page(@page).per(@limit)27 @games_next = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order(name: :desc).page(@page.to_i + 1).per(@limit)28 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order(name: :desc).page(@page.to_i + 2).per(@limit)29 elsif @filter == "release_date_desc"30 @games = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page).per(@limit)31 @games_next = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 1).per(@limit)32 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 2).per(@limit)33 elsif @filter == "release_date_asc"34 @games = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date ASC").page(@page).per(@limit)35 @games_next = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date ASC").page(@page.to_i + 1).per(@limit)36 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date ASC").page(@page.to_i + 2).per(@limit)37 else38 @games = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page).per(@limit)39 @games_next = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 1).per(@limit)40 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.platform_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 2).per(@limit)41 end42 elsif @sort_attribute == "genre"43 if @filter == "name_up"44 @games = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order(:name).page(@page).per(@limit)45 @games_next = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order(:name).page(@page.to_i + 1).per(@limit)46 @games_next_2 = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order(:name).page(@page.to_i + 2).per(@limit)47 elsif @filter == "name_down"48 @games = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order(name: :desc).page(@page).per(@limit)49 @games_next = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order(name: :desc).page(@page.to_i + 1).per(@limit)50 @games_next_2 = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order(name: :desc).page(@page.to_i + 2).per(@limit)51 elsif @filter == "release_date_desc"52 @games = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date DESC").page(@page).per(@limit)53 @games_next = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 1).per(@limit)54 @games_next_2 = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 2).per(@limit)55 elsif @filter == "release_date_asc"56 @games = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date ASC").page(@page).per(@limit)57 @games_next = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date ASC").page(@page.to_i + 1).per(@limit)58 @games_next_2 = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date ASC").page(@page.to_i + 2).per(@limit)59 else60 @games = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date DESC").page(@page).per(@limit)61 @games_next = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 1).per(@limit)62 @games_next_2 = Game.includes(:genred_games, :platformed_games).where("genred_games.genre_id = #{@sort_attribute_2}").where("platformed_games.id >= 0").references(:genred_games, :platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 2).per(@limit)63 end64 elsif @filter == "name_up"65 @games = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order(:name).page(@page).per(@limit)66 @games_next = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order(:name).page(@page.to_i + 1).per(@limit)67 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order(:name).page(@page.to_i + 2).per(@limit)68 elsif @filter == "name_down"69 @games = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order(name: :desc).page(@page).per(@limit)70 @games_next = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order(name: :desc).page(@page.to_i + 1).per(@limit)71 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order(name: :desc).page(@page.to_i + 2).per(@limit)72 elsif @filter == "release_date_desc"73 @games = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page).per(@limit)74 @games_next = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 1).per(@limit)75 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 2).per(@limit)76 elsif @filter == "release_date_asc"77 @games = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date ASC").page(@page).per(@limit)78 @games_next = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date ASC").page(@page.to_i + 1).per(@limit)79 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date ASC").page(@page.to_i + 2).per(@limit)80 else81 @games = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page).per(@limit)82 @games_next = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 1).per(@limit)83 @games_next_2 = Game.includes(:platformed_games).where("platformed_games.id >= 0").references(:platformed_games).order("platformed_games.release_date DESC").page(@page.to_i + 2).per(@limit)84 end85 @platforms_1 = Platform.where.not(release_date: nil).order(release_date: :desc)86 @platforms_2 = Platform.where(release_date: nil).order(:name)87 @platforms = @platforms_1 | @platforms_288 @genres = Genre.all.order(:name)89 if @games.any?90 @sample_games = []91 index = 0 92 counter = 093 until @sample_games.length >= 294 sample = @games.includes(:game_covers).where("game_covers.id >= 0").references(:game_covers).sample95 if !@sample_games.include?(sample) && sample.game_covers96 @sample_games << sample97 index += 198 counter = 099 end100 counter += 1101 if counter == 5102 break103 end104 end105 end106 end107 def index_2108 @counter = 0109 sort_attribute= params[:sort_attribute]110 sort_attribute_2 = params[:sort_attribute_2]111 if sort_attribute == "platform"112 @games = Game.includes(:platformed_games).where("platformed_games.platform_id = #{sort_attribute_2}").references(:platformed_games).order(:name)113 # if sort_attribute_2 == "1"114 # @games = Game.includes(:platformed_games).where('platformed_games.platform_id = 1').references(:platformed_games).order(:name) #ps4115 # elsif sort_attribute_2 == "2"116 # @games = Game.includes(:platformed_games).where('platformed_games.platform_id = 2').references(:platformed_games).order(:name) #xbone117 # elsif sort_attribute_2 == "3"118 # @games = Game.includes(:platformed_games).where('platformed_games.platform_id = 3').references(:platformed_games).order(:name) #wii u119 # elsif sort_attribute_2 == "4"120 # @games = Game.includes(:platformed_games).where('platformed_games.platform_id = 4').references(:platformed_games).order(:name) #pc121 # end122 elsif sort_attribute == "genre"123 @games = Game.includes(:genred_games).where("genred_games.genre_id = #{sort_attribute_2}").references(:genred_games).order(:name)124 # if sort_attribute_2 == "1"125 # @games = Game.includes(:genred_games).where('genred_games.genre_id = 1').references(:genred_games).order(:name) #action-rpg126 # elsif sort_attribute_2 == "2"127 # @games = Game.includes(:genred_games).where('genred_games.genre_id = 2').references(:genred_games).order(:name) #fps128 # elsif sort_attribute_2 == "3"129 # @games = Game.includes(:genred_games).where('genred_games.genre_id = 3').references(:genred_games).order(:name) #survival-horror130 # elsif sort_attribute_2 == "4"131 # @games = Game.includes(:genred_games).where('genred_games.genre_id = 4').references(:genred_games).order(:name) #action-rpg132 # end133 else134 @games = Game.where("name LIKE ?", "%Metal Gear Solid%").order(:name).limit(15)135 end136 end137 def show138 @game = Game.find_by(id: params[:id])139 @game_images = []140 if @game.game_covers.any?141 @game_images << @game.game_covers.first142 end143 if @game.game_screenshots.any?144 @game.game_screenshots.each do |screenshot|145 @game_images << screenshot146 end147 end148 @index = 0...
testflight.rb
Source:testflight.rb
...4 module TestFlight5 #6 # apps7 #8 def get_apps(filter: {}, includes: nil, limit: nil, sort: nil)9 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)10 Client.instance.get("apps", params)11 end12 def get_app(app_id: nil, includes: nil)13 params = Client.instance.build_params(filter: nil, includes: includes, limit: nil, sort: nil)14 Client.instance.get("apps/#{app_id}", params)15 end16 #17 # betaAppLocalizations18 #19 def get_beta_app_localizations(filter: {}, includes: nil, limit: nil, sort: nil)20 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)21 Client.instance.get("betaAppLocalizations", params)22 end23 def post_beta_app_localizations(app_id: nil, attributes: {})24 body = {25 data: {26 attributes: attributes,27 type: "betaAppLocalizations",28 relationships: {29 app: {30 data: {31 type: "apps",32 id: app_id33 }34 }35 }36 }37 }38 Client.instance.post("betaAppLocalizations", body)39 end40 def patch_beta_app_localizations(localization_id: nil, attributes: {})41 body = {42 data: {43 attributes: attributes,44 id: localization_id,45 type: "betaAppLocalizations"46 }47 }48 Client.instance.patch("betaAppLocalizations/#{localization_id}", body)49 end50 #51 # betaAppReviewDetails52 #53 def get_beta_app_review_detail(filter: {}, includes: nil, limit: nil, sort: nil)54 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)55 Client.instance.get("betaAppReviewDetails", params)56 end57 def patch_beta_app_review_detail(app_id: nil, attributes: {})58 body = {59 data: {60 attributes: attributes,61 id: app_id,62 type: "betaAppReviewDetails"63 }64 }65 Client.instance.patch("betaAppReviewDetails/#{app_id}", body)66 end67 #68 # betaAppReviewSubmissions69 #70 def get_beta_app_review_submissions(filter: {}, includes: nil, limit: nil, sort: nil, cursor: nil)71 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort, cursor: cursor)72 Client.instance.get("betaAppReviewSubmissions", params)73 end74 def post_beta_app_review_submissions(build_id: nil)75 body = {76 data: {77 type: "betaAppReviewSubmissions",78 relationships: {79 build: {80 data: {81 type: "builds",82 id: build_id83 }84 }85 }86 }87 }88 Client.instance.post("betaAppReviewSubmissions", body)89 end90 def delete_beta_app_review_submission(beta_app_review_submission_id: nil)91 params = Client.instance.build_params(filter: nil, includes: nil, limit: nil, sort: nil, cursor: nil)92 Client.instance.delete("betaAppReviewSubmissions/#{beta_app_review_submission_id}", params)93 end94 #95 # betaBuildLocalizations96 #97 def get_beta_build_localizations(filter: {}, includes: nil, limit: nil, sort: nil)98 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)99 Client.instance.get("betaBuildLocalizations", params)100 end101 def post_beta_build_localizations(build_id: nil, attributes: {})102 body = {103 data: {104 attributes: attributes,105 type: "betaBuildLocalizations",106 relationships: {107 build: {108 data: {109 type: "builds",110 id: build_id111 }112 }113 }114 }115 }116 Client.instance.post("betaBuildLocalizations", body)117 end118 def patch_beta_build_localizations(localization_id: nil, feedbackEmail: nil, attributes: {})119 body = {120 data: {121 attributes: attributes,122 id: localization_id,123 type: "betaBuildLocalizations"124 }125 }126 Client.instance.patch("betaBuildLocalizations/#{localization_id}", body)127 end128 #129 # betaBuildMetrics130 #131 def get_beta_build_metrics(filter: {}, includes: nil, limit: nil, sort: nil)132 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)133 Client.instance.get("betaBuildMetrics", params)134 end135 #136 # betaGroups137 #138 def get_beta_groups(filter: {}, includes: nil, limit: nil, sort: nil)139 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)140 Client.instance.get("betaGroups", params)141 end142 def add_beta_groups_to_build(build_id: nil, beta_group_ids: [])143 body = {144 data: beta_group_ids.map do |id|145 {146 type: "betaGroups",147 id: id148 }149 end150 }151 Client.instance.post("builds/#{build_id}/relationships/betaGroups", body)152 end153 def create_beta_group(app_id: nil, group_name: nil, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false)154 body = {155 data: {156 attributes: {157 name: group_name,158 publicLinkEnabled: public_link_enabled,159 publicLinkLimit: public_link_limit,160 publicLinkLimitEnabled: public_link_limit_enabled161 },162 relationships: {163 app: {164 data: {165 id: app_id,166 type: "apps"167 }168 }169 },170 type: "betaGroups"171 }172 }173 Client.instance.post("betaGroups", body)174 end175 #176 # betaTesters177 #178 def get_beta_testers(filter: {}, includes: nil, limit: nil, sort: nil)179 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)180 Client.instance.get("betaTesters", params)181 end182 # beta_testers - [{email: "", firstName: "", lastName: ""}]183 def post_bulk_beta_tester_assignments(beta_group_id: nil, beta_testers: nil)184 beta_testers || []185 beta_testers.map do |tester|186 tester[:errors] = []187 end188 body = {189 data: {190 attributes: {191 betaTesters: beta_testers192 },193 relationships: {194 betaGroup: {195 data: {196 type: "betaGroups",197 id: beta_group_id198 }199 }200 },201 type: "bulkBetaTesterAssignments"202 }203 }204 Client.instance.post("bulkBetaTesterAssignments", body)205 end206 def delete_beta_tester_from_apps(beta_tester_id: nil, app_ids: [])207 body = {208 data: app_ids.map do |id|209 {210 type: "apps",211 id: id212 }213 end214 }215 Client.instance.delete("betaTesters/#{beta_tester_id}/relationships/apps", nil, body)216 end217 def delete_beta_tester_from_beta_groups(beta_tester_id: nil, beta_group_ids: [])218 body = {219 data: beta_group_ids.map do |id|220 {221 type: "betaGroups",222 id: id223 }224 end225 }226 Client.instance.delete("betaTesters/#{beta_tester_id}/relationships/betaGroups", nil, body)227 end228 #229 # betaTesterMetrics230 #231 def get_beta_tester_metrics(filter: {}, includes: nil, limit: nil, sort: nil)232 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)233 Client.instance.get("betaTesterMetrics", params)234 end235 #236 # builds237 #238 def get_builds(filter: {}, includes: "buildBetaDetail,betaBuildMetrics", limit: 10, sort: "uploadedDate", cursor: nil)239 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort, cursor: cursor)240 Client.instance.get("builds", params)241 end242 def get_build(build_id: nil, app_store_version_id: nil, includes: nil)243 if build_id244 params = Client.instance.build_params(filter: nil, includes: includes, limit: nil, sort: nil, cursor: nil)245 return Client.instance.get("builds/#{build_id}", params)246 elsif app_store_version_id247 params = Client.instance.build_params(filter: nil, includes: includes, limit: nil, sort: nil, cursor: nil)248 return Client.instance.get("appStoreVersions/#{app_store_version_id}/build", params)249 else250 return nil251 end252 end253 def patch_builds(build_id: nil, attributes: {})254 body = {255 data: {256 attributes: attributes,257 id: build_id,258 type: "builds"259 }260 }261 Client.instance.patch("builds/#{build_id}", body)262 end263 #264 # buildBetaDetails265 #266 def get_build_beta_details(filter: {}, includes: nil, limit: nil, sort: nil)267 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)268 Client.instance.get("buildBetaDetails", params)269 end270 def patch_build_beta_details(build_beta_details_id: nil, attributes: {})271 body = {272 data: {273 attributes: attributes,274 id: build_beta_details_id,275 type: "buildBetaDetails"276 }277 }278 Client.instance.patch("buildBetaDetails/#{build_beta_details_id}", body)279 end280 #281 # buildDeliveries282 #283 def get_build_deliveries(filter: {}, includes: nil, limit: nil, sort: nil)284 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)285 Client.instance.get("buildDeliveries", params)286 end287 #288 # preReleaseVersions289 #290 def get_pre_release_versions(filter: {}, includes: nil, limit: nil, sort: nil)291 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)292 Client.instance.get("preReleaseVersions", params)293 end294 #295 # betaFeedbacks (private API as of end 2019)296 #297 def get_beta_feedback(filter: {}, includes: nil, limit: nil, sort: nil)298 params = Client.instance.build_params(filter: filter, includes: includes, limit: limit, sort: sort)299 Client.instance.get("betaFeedbacks", params)300 end301 def delete_beta_feedback(feedback_id: nil)302 raise "Feedback id is nil" if feedback_id.nil?303 Client.instance.delete("betaFeedbacks/#{feedback_id}")304 end305 end306 end307end...
limit
Using AI Code Generation
1 def limit(arr, limit)2 arr.sort.first(limit)3puts sort.limit(arr, 3)
limit
Using AI Code Generation
1 assert_equal([1,2,3,4,5], @sort.limit([1,2,3,4,5], 5))2 assert_equal([1,2,3,4,5], @sort.limit([5,4,3,2,1], 5))3 assert_equal([1,2,3,4,5], @sort.limit([3,4,1,2,5], 5))4 assert_equal([1,2,3,4,5], @sort.limit([5,4,1,2,3], 5))5 assert_equal([1,2,3,4,5], @sort.limit([3,4,5,2,1], 5))6 assert_equal([1,2,3,4,5], @sort.limit([1,2,3,4,5], 5))7 assert_equal([1,2,3,4,5], @sort.limit([5,4,3,2,1], 5))8 assert_equal([1,2,3,4,5], @sort.limit([3,4,1,2,5], 5))9 assert_equal([1,2,3,4,5], @sort.limit([5,4,1,2,3], 5))10 assert_equal([1,2,3,4,5], @sort.limit([3,4,5,2,1], 5))
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!