loading
Generated 2021-08-08T12:01:52+02:00

All Files ( 2.98% covered at 0.03 hits/line )

97 files in total.
1274 relevant lines, 38 lines covered and 1236 lines missed. ( 2.98% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/channels/application_cable/channel.rb 0.00 % 6 4 0 4 0.00
app/channels/application_cable/connection.rb 0.00 % 6 4 0 4 0.00
app/controllers/application_controller.rb 0.00 % 28 22 0 22 0.00
app/controllers/home_controller.rb 0.00 % 5 3 0 3 0.00
app/controllers/protected_controller.rb 0.00 % 6 4 0 4 0.00
app/controllers/rp_worlds_controller.rb 0.00 % 54 34 0 34 0.00
app/controllers/users/omniauth_callbacks_controller.rb 0.00 % 34 26 0 26 0.00
app/controllers/wow_characters_controller.rb 0.00 % 26 23 0 23 0.00
app/controllers/wow_mounts_controller.rb 0.00 % 11 8 0 8 0.00
app/controllers/wow_pets_controller.rb 0.00 % 11 8 0 8 0.00
app/controllers/wow_reputations_controller.rb 0.00 % 11 8 0 8 0.00
app/helpers/application_helper.rb 33.33 % 20 9 3 6 0.33
app/helpers/home_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/protected_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/rp_world_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/welcome_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/wow_characters_helper.rb 28.57 % 16 7 2 5 0.29
app/helpers/wow_classes_helper.rb 40.00 % 12 5 2 3 0.40
app/helpers/wow_mounts_helper.rb 66.67 % 7 3 2 1 0.67
app/helpers/wow_pets_helper.rb 66.67 % 7 3 2 1 0.67
app/helpers/wow_races_helper.rb 40.00 % 12 5 2 3 0.40
app/helpers/wow_reputations_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/wow_standings_helper.rb 22.22 % 15 9 2 7 0.22
app/jobs/application_job.rb 0.00 % 9 2 0 2 0.00
app/mailers/application_mailer.rb 0.00 % 6 4 0 4 0.00
app/models/application_record.rb 100.00 % 5 2 2 0 1.00
app/models/learned_wow_pet_ability.rb 0.00 % 6 4 0 4 0.00
app/models/rp_world.rb 0.00 % 11 8 0 8 0.00
app/models/user.rb 45.45 % 40 22 10 12 0.45
app/models/user_obtain_wow_mount.rb 0.00 % 6 4 0 4 0.00
app/models/user_obtain_wow_pet.rb 0.00 % 6 4 0 4 0.00
app/models/wow_character.rb 0.00 % 25 21 0 21 0.00
app/models/wow_character_medium.rb 0.00 % 5 3 0 3 0.00
app/models/wow_character_play_rp_world.rb 0.00 % 9 6 0 6 0.00
app/models/wow_character_title.rb 0.00 % 11 7 0 7 0.00
app/models/wow_class.rb 0.00 % 11 7 0 7 0.00
app/models/wow_covenant.rb 0.00 % 12 8 0 8 0.00
app/models/wow_covenant_progress.rb 0.00 % 6 4 0 4 0.00
app/models/wow_creature.rb 0.00 % 12 8 0 8 0.00
app/models/wow_creature_family.rb 0.00 % 11 7 0 7 0.00
app/models/wow_creature_type.rb 0.00 % 11 7 0 7 0.00
app/models/wow_geo_map.rb 0.00 % 11 7 0 7 0.00
app/models/wow_geo_position.rb 0.00 % 21 18 0 18 0.00
app/models/wow_geo_zone.rb 0.00 % 11 7 0 7 0.00
app/models/wow_guild.rb 0.00 % 12 8 0 8 0.00
app/models/wow_item.rb 0.00 % 14 10 0 10 0.00
app/models/wow_item_class.rb 0.00 % 12 8 0 8 0.00
app/models/wow_item_inventory_type.rb 0.00 % 11 7 0 7 0.00
app/models/wow_item_quality.rb 0.00 % 11 7 0 7 0.00
app/models/wow_item_sub_class.rb 0.00 % 11 7 0 7 0.00
app/models/wow_mount.rb 0.00 % 12 8 0 8 0.00
app/models/wow_pet.rb 0.00 % 14 10 0 10 0.00
app/models/wow_pet_ability.rb 0.00 % 12 8 0 8 0.00
app/models/wow_race.rb 100.00 % 11 6 6 0 1.00
app/models/wow_realm.rb 0.00 % 12 8 0 8 0.00
app/models/wow_reputation.rb 0.00 % 22 17 0 17 0.00
app/models/wow_reputation_tier.rb 0.00 % 8 5 0 5 0.00
app/models/wow_reputation_tier_level.rb 0.00 % 13 8 0 8 0.00
app/models/wow_spell.rb 0.00 % 9 6 0 6 0.00
app/models/wow_standing.rb 0.00 % 9 6 0 6 0.00
app/workers/wow_character_detail_worker.rb 0.00 % 50 34 0 34 0.00
app/workers/wow_character_media_worker.rb 0.00 % 35 26 0 26 0.00
app/workers/wow_character_positions_worker.rb 0.00 % 66 54 0 54 0.00
app/workers/wow_character_title_detail_worker.rb 0.00 % 22 15 0 15 0.00
app/workers/wow_character_titles_worker.rb 0.00 % 26 17 0 17 0.00
app/workers/wow_characters_worker.rb 0.00 % 46 35 0 35 0.00
app/workers/wow_class_detail_worker.rb 0.00 % 23 16 0 16 0.00
app/workers/wow_classes_worker.rb 0.00 % 26 17 0 17 0.00
app/workers/wow_covenant_detail_worker.rb 0.00 % 23 15 0 15 0.00
app/workers/wow_covenants_worker.rb 0.00 % 24 16 0 16 0.00
app/workers/wow_creature_families_worker.rb 0.00 % 22 15 0 15 0.00
app/workers/wow_creature_types_worker.rb 0.00 % 22 15 0 15 0.00
app/workers/wow_creatures_worker.rb 0.00 % 42 29 0 29 0.00
app/workers/wow_guild_detail_worker.rb 0.00 % 32 22 0 22 0.00
app/workers/wow_item_class_detail_worker.rb 0.00 % 18 12 0 12 0.00
app/workers/wow_item_classes_worker.rb 0.00 % 24 16 0 16 0.00
app/workers/wow_item_sub_class_detail_worker.rb 0.00 % 26 19 0 19 0.00
app/workers/wow_items_worker.rb 0.00 % 83 58 0 58 0.00
app/workers/wow_mount_detail_worker.rb 0.00 % 31 21 0 21 0.00
app/workers/wow_mounts_collection_worker.rb 0.00 % 18 12 0 12 0.00
app/workers/wow_mounts_worker.rb 0.00 % 27 17 0 17 0.00
app/workers/wow_pet_abilities_worker.rb 0.00 % 26 17 0 17 0.00
app/workers/wow_pet_ability_detail_worker.rb 0.00 % 30 21 0 21 0.00
app/workers/wow_pet_detail_worker.rb 0.00 % 47 35 0 35 0.00
app/workers/wow_pets_collection_worker.rb 0.00 % 18 12 0 12 0.00
app/workers/wow_pets_worker.rb 0.00 % 27 17 0 17 0.00
app/workers/wow_race_detail_worker.rb 0.00 % 27 19 0 19 0.00
app/workers/wow_races_worker.rb 0.00 % 27 17 0 17 0.00
app/workers/wow_realm_detail_worker.rb 0.00 % 26 18 0 18 0.00
app/workers/wow_realms_worker.rb 0.00 % 27 18 0 18 0.00
app/workers/wow_reputation_detail_worker.rb 0.00 % 31 20 0 20 0.00
app/workers/wow_reputation_tier_detail_worker.rb 0.00 % 32 22 0 22 0.00
app/workers/wow_reputation_tiers_worker.rb 0.00 % 22 14 0 14 0.00
app/workers/wow_reputations_worker.rb 0.00 % 29 19 0 19 0.00
app/workers/wow_sidekiq_worker.rb 0.00 % 22 19 0 19 0.00
app/workers/wow_spells_worker.rb 0.00 % 38 26 0 26 0.00
app/workers/wow_standing_worker.rb 0.00 % 28 20 0 20 0.00

Controllers ( 0.0% covered at 0.0 hits/line )

9 files in total.
136 relevant lines, 0 lines covered and 136 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/controllers/application_controller.rb 0.00 % 28 22 0 22 0.00
app/controllers/home_controller.rb 0.00 % 5 3 0 3 0.00
app/controllers/protected_controller.rb 0.00 % 6 4 0 4 0.00
app/controllers/rp_worlds_controller.rb 0.00 % 54 34 0 34 0.00
app/controllers/users/omniauth_callbacks_controller.rb 0.00 % 34 26 0 26 0.00
app/controllers/wow_characters_controller.rb 0.00 % 26 23 0 23 0.00
app/controllers/wow_mounts_controller.rb 0.00 % 11 8 0 8 0.00
app/controllers/wow_pets_controller.rb 0.00 % 11 8 0 8 0.00
app/controllers/wow_reputations_controller.rb 0.00 % 11 8 0 8 0.00

Channels ( 0.0% covered at 0.0 hits/line )

2 files in total.
8 relevant lines, 0 lines covered and 8 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/channels/application_cable/channel.rb 0.00 % 6 4 0 4 0.00
app/channels/application_cable/connection.rb 0.00 % 6 4 0 4 0.00

Models ( 6.36% covered at 0.06 hits/line )

35 files in total.
283 relevant lines, 18 lines covered and 265 lines missed. ( 6.36% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/models/application_record.rb 100.00 % 5 2 2 0 1.00
app/models/learned_wow_pet_ability.rb 0.00 % 6 4 0 4 0.00
app/models/rp_world.rb 0.00 % 11 8 0 8 0.00
app/models/user.rb 45.45 % 40 22 10 12 0.45
app/models/user_obtain_wow_mount.rb 0.00 % 6 4 0 4 0.00
app/models/user_obtain_wow_pet.rb 0.00 % 6 4 0 4 0.00
app/models/wow_character.rb 0.00 % 25 21 0 21 0.00
app/models/wow_character_medium.rb 0.00 % 5 3 0 3 0.00
app/models/wow_character_play_rp_world.rb 0.00 % 9 6 0 6 0.00
app/models/wow_character_title.rb 0.00 % 11 7 0 7 0.00
app/models/wow_class.rb 0.00 % 11 7 0 7 0.00
app/models/wow_covenant.rb 0.00 % 12 8 0 8 0.00
app/models/wow_covenant_progress.rb 0.00 % 6 4 0 4 0.00
app/models/wow_creature.rb 0.00 % 12 8 0 8 0.00
app/models/wow_creature_family.rb 0.00 % 11 7 0 7 0.00
app/models/wow_creature_type.rb 0.00 % 11 7 0 7 0.00
app/models/wow_geo_map.rb 0.00 % 11 7 0 7 0.00
app/models/wow_geo_position.rb 0.00 % 21 18 0 18 0.00
app/models/wow_geo_zone.rb 0.00 % 11 7 0 7 0.00
app/models/wow_guild.rb 0.00 % 12 8 0 8 0.00
app/models/wow_item.rb 0.00 % 14 10 0 10 0.00
app/models/wow_item_class.rb 0.00 % 12 8 0 8 0.00
app/models/wow_item_inventory_type.rb 0.00 % 11 7 0 7 0.00
app/models/wow_item_quality.rb 0.00 % 11 7 0 7 0.00
app/models/wow_item_sub_class.rb 0.00 % 11 7 0 7 0.00
app/models/wow_mount.rb 0.00 % 12 8 0 8 0.00
app/models/wow_pet.rb 0.00 % 14 10 0 10 0.00
app/models/wow_pet_ability.rb 0.00 % 12 8 0 8 0.00
app/models/wow_race.rb 100.00 % 11 6 6 0 1.00
app/models/wow_realm.rb 0.00 % 12 8 0 8 0.00
app/models/wow_reputation.rb 0.00 % 22 17 0 17 0.00
app/models/wow_reputation_tier.rb 0.00 % 8 5 0 5 0.00
app/models/wow_reputation_tier_level.rb 0.00 % 13 8 0 8 0.00
app/models/wow_spell.rb 0.00 % 9 6 0 6 0.00
app/models/wow_standing.rb 0.00 % 9 6 0 6 0.00

Mailers ( 0.0% covered at 0.0 hits/line )

1 files in total.
4 relevant lines, 0 lines covered and 4 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/mailers/application_mailer.rb 0.00 % 6 4 0 4 0.00

Helpers ( 43.48% covered at 0.43 hits/line )

12 files in total.
46 relevant lines, 20 lines covered and 26 lines missed. ( 43.48% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/helpers/application_helper.rb 33.33 % 20 9 3 6 0.33
app/helpers/home_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/protected_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/rp_world_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/welcome_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/wow_characters_helper.rb 28.57 % 16 7 2 5 0.29
app/helpers/wow_classes_helper.rb 40.00 % 12 5 2 3 0.40
app/helpers/wow_mounts_helper.rb 66.67 % 7 3 2 1 0.67
app/helpers/wow_pets_helper.rb 66.67 % 7 3 2 1 0.67
app/helpers/wow_races_helper.rb 40.00 % 12 5 2 3 0.40
app/helpers/wow_reputations_helper.rb 100.00 % 4 1 1 0 1.00
app/helpers/wow_standings_helper.rb 22.22 % 15 9 2 7 0.22

Jobs ( 0.0% covered at 0.0 hits/line )

38 files in total.
797 relevant lines, 0 lines covered and 797 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/jobs/application_job.rb 0.00 % 9 2 0 2 0.00
app/workers/wow_character_detail_worker.rb 0.00 % 50 34 0 34 0.00
app/workers/wow_character_media_worker.rb 0.00 % 35 26 0 26 0.00
app/workers/wow_character_positions_worker.rb 0.00 % 66 54 0 54 0.00
app/workers/wow_character_title_detail_worker.rb 0.00 % 22 15 0 15 0.00
app/workers/wow_character_titles_worker.rb 0.00 % 26 17 0 17 0.00
app/workers/wow_characters_worker.rb 0.00 % 46 35 0 35 0.00
app/workers/wow_class_detail_worker.rb 0.00 % 23 16 0 16 0.00
app/workers/wow_classes_worker.rb 0.00 % 26 17 0 17 0.00
app/workers/wow_covenant_detail_worker.rb 0.00 % 23 15 0 15 0.00
app/workers/wow_covenants_worker.rb 0.00 % 24 16 0 16 0.00
app/workers/wow_creature_families_worker.rb 0.00 % 22 15 0 15 0.00
app/workers/wow_creature_types_worker.rb 0.00 % 22 15 0 15 0.00
app/workers/wow_creatures_worker.rb 0.00 % 42 29 0 29 0.00
app/workers/wow_guild_detail_worker.rb 0.00 % 32 22 0 22 0.00
app/workers/wow_item_class_detail_worker.rb 0.00 % 18 12 0 12 0.00
app/workers/wow_item_classes_worker.rb 0.00 % 24 16 0 16 0.00
app/workers/wow_item_sub_class_detail_worker.rb 0.00 % 26 19 0 19 0.00
app/workers/wow_items_worker.rb 0.00 % 83 58 0 58 0.00
app/workers/wow_mount_detail_worker.rb 0.00 % 31 21 0 21 0.00
app/workers/wow_mounts_collection_worker.rb 0.00 % 18 12 0 12 0.00
app/workers/wow_mounts_worker.rb 0.00 % 27 17 0 17 0.00
app/workers/wow_pet_abilities_worker.rb 0.00 % 26 17 0 17 0.00
app/workers/wow_pet_ability_detail_worker.rb 0.00 % 30 21 0 21 0.00
app/workers/wow_pet_detail_worker.rb 0.00 % 47 35 0 35 0.00
app/workers/wow_pets_collection_worker.rb 0.00 % 18 12 0 12 0.00
app/workers/wow_pets_worker.rb 0.00 % 27 17 0 17 0.00
app/workers/wow_race_detail_worker.rb 0.00 % 27 19 0 19 0.00
app/workers/wow_races_worker.rb 0.00 % 27 17 0 17 0.00
app/workers/wow_realm_detail_worker.rb 0.00 % 26 18 0 18 0.00
app/workers/wow_realms_worker.rb 0.00 % 27 18 0 18 0.00
app/workers/wow_reputation_detail_worker.rb 0.00 % 31 20 0 20 0.00
app/workers/wow_reputation_tier_detail_worker.rb 0.00 % 32 22 0 22 0.00
app/workers/wow_reputation_tiers_worker.rb 0.00 % 22 14 0 14 0.00
app/workers/wow_reputations_worker.rb 0.00 % 29 19 0 19 0.00
app/workers/wow_sidekiq_worker.rb 0.00 % 22 19 0 19 0.00
app/workers/wow_spells_worker.rb 0.00 % 38 26 0 26 0.00
app/workers/wow_standing_worker.rb 0.00 % 28 20 0 20 0.00

Libraries ( 100.0% covered at 0.0 hits/line )

0 files in total.
0 relevant lines, 0 lines covered and 0 lines missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line

app/channels/application_cable/channel.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. module ApplicationCable
  3. class Channel < ActionCable::Channel::Base
  4. end
  5. end

app/channels/application_cable/connection.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. module ApplicationCable
  3. class Connection < ActionCable::Connection::Base
  4. end
  5. end

app/controllers/application_controller.rb

0.0% lines covered

22 relevant lines. 0 lines covered and 22 lines missed.
    
  1. # frozen_string_literal: true
  2. class ApplicationController < ActionController::Base
  3. around_action :switch_locale
  4. def switch_locale(&action)
  5. locale = extract_locale
  6. I18n.with_locale(locale, &action)
  7. end
  8. def new_session_path(_scope)
  9. new_user_session_path
  10. end
  11. def extract_locale
  12. if params[:locale]
  13. I18n.locale_available?(params[:locale]) ? params[:locale] : I18n.default_locale
  14. elsif request.env['HTTP_ACCEPT_LANGUAGE']
  15. I18n.locale_available?(request.env['HTTP_ACCEPT_LANGUAGE']) ? request.env['HTTP_ACCEPT_LANGUAGE'] : I18n.default_locale
  16. else
  17. I18n.default_locale
  18. end
  19. end
  20. def default_url_options
  21. { locale: I18n.locale }
  22. end
  23. end

app/controllers/home_controller.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. # frozen_string_literal: true
  2. class HomeController < ApplicationController
  3. def index; end
  4. end

app/controllers/protected_controller.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. class ProtectedController < ApplicationController
  3. before_action :authenticate_user!
  4. include Pagy::Backend
  5. end

app/controllers/rp_worlds_controller.rb

0.0% lines covered

34 relevant lines. 0 lines covered and 34 lines missed.
    
  1. # frozen_string_literal: true
  2. class RpWorldsController < ApplicationController
  3. before_action :set_rp_world, only: [:show, :edit, :update, :destroy]
  4. # GET /rp_worlds
  5. def index
  6. @rp_worlds = RpWorld.all
  7. end
  8. # GET /rp_worlds/1
  9. def show; end
  10. # GET /rp_worlds/1/edit
  11. def edit; end
  12. # POST /rp_worlds
  13. def create
  14. @rp_world = RpWorld.new(rp_world_params)
  15. if @rp_world.save
  16. redirect_to @rp_world, notice: 'Rp world was successfully created.'
  17. else
  18. render :new
  19. end
  20. end
  21. # PATCH/PUT /rp_worlds/1
  22. def update
  23. if @rp_world.update(rp_world_params)
  24. redirect_to @rp_world, notice: 'Rp world was successfully updated.'
  25. else
  26. render :edit
  27. end
  28. end
  29. # DELETE /rp_worlds/1
  30. def destroy
  31. @rp_world.destroy
  32. redirect_to rp_worlds_url, notice: 'Rp world was successfully destroyed.'
  33. end
  34. private
  35. # Use callbacks to share common setup or constraints between actions.
  36. def set_rp_world
  37. @rp_world = RpWorld.includes(:wow_characters).find(params[:id])
  38. end
  39. # Only allow a list of trusted parameters through.
  40. def rp_world_params
  41. params.require(:rp_world).permit(:name, :description)
  42. end
  43. end

app/controllers/users/omniauth_callbacks_controller.rb

0.0% lines covered

26 relevant lines. 0 lines covered and 26 lines missed.
    
  1. # frozen_string_literal: true
  2. # Controller: Callback
  3. #
  4. # Description: Callback method for Bnet
  5. module Users
  6. class OmniauthCallbacksController < Devise::OmniauthCallbacksController
  7. skip_before_action :verify_authenticity_token, only: :bnet
  8. def bnet
  9. @user = User.from_omniauth(request.env['omniauth.auth'])
  10. if @user.persisted?
  11. unless ENV['ALLOWED_BNET_USERS'].split(',').include?(@user.battletag)
  12. set_flash_message(:alert, :not_authorized)
  13. redirect_to root_path
  14. return
  15. end
  16. sign_in_and_redirect @user, event: :authentication
  17. WowCharactersWorker.perform_async(@user.id)
  18. WowMountsCollectionWorker.perform_async(@user.id)
  19. WowPetsCollectionWorker.perform_async(@user.id)
  20. set_flash_message(:notice, :success, kind: 'Bnet') if is_navigational_format?
  21. else
  22. session['devise.bnet_data'] = request.env['omniauth.auth'].except(:extra)
  23. redirect_to new_user_registration_url
  24. end
  25. end
  26. def failure
  27. redirect_to root_path
  28. end
  29. end
  30. end

app/controllers/wow_characters_controller.rb

0.0% lines covered

23 relevant lines. 0 lines covered and 23 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharactersController < ProtectedController
  3. def index
  4. @wow_characters = current_user.wow_characters.includes(
  5. :wow_realm,
  6. :wow_race,
  7. :wow_class,
  8. :wow_character_medium,
  9. :wow_guild,
  10. :wow_covenant
  11. )
  12. end
  13. def show
  14. @wow_character = current_user.wow_characters.includes(
  15. wow_standings: {
  16. wow_reputation: {
  17. wow_reputation_tier: :wow_reputation_tier_levels
  18. }
  19. }
  20. ).find(params[:id])
  21. meta_reputation_ids = @wow_character.wow_standings.map { |standing| standing.wow_reputation.meta_wow_reputation_id }.uniq
  22. @meta_wow_reputations = WowReputation.find(meta_reputation_ids)
  23. end
  24. end

app/controllers/wow_mounts_controller.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowMountsController < ProtectedController
  3. def index
  4. @pagy, @wow_mounts = pagy(WowMount.includes(:users), items: 12)
  5. end
  6. def show
  7. @wow_mount = WowMount.find(params[:id])
  8. end
  9. end

app/controllers/wow_pets_controller.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetsController < ProtectedController
  3. def index
  4. @pagy, @wow_pets = pagy(WowPet.includes(:users), items: 12)
  5. end
  6. def show
  7. @wow_pet = WowPet.find(params[:id])
  8. end
  9. end

app/controllers/wow_reputations_controller.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationsController < ProtectedController
  3. def index
  4. @pagy, @wow_reputations = pagy(WowReputation.non_meta_reputations, items: 20)
  5. end
  6. def show
  7. @wow_reputation = WowReputation.find(params[:id])
  8. end
  9. end

app/helpers/application_helper.rb

33.33% lines covered

9 relevant lines. 3 lines covered and 6 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module ApplicationHelper
  3. 1 include Pagy::Frontend
  4. 1 def bootstrap_class_for_flash(flash_type)
  5. case flash_type
  6. when 'success'
  7. 'alert-success'
  8. when 'error'
  9. 'alert-danger'
  10. when 'alert'
  11. 'alert-warning'
  12. when 'notice'
  13. 'alert-primary'
  14. else
  15. 'alert-secondary'
  16. end
  17. end
  18. end

app/helpers/home_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module HomeHelper
  3. end

app/helpers/protected_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module ProtectedHelper
  3. end

app/helpers/rp_world_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module RpWorldHelper
  3. end

app/helpers/welcome_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WelcomeHelper
  3. end

app/helpers/wow_characters_helper.rb

28.57% lines covered

7 relevant lines. 2 lines covered and 5 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowCharactersHelper
  3. 1 def wow_character_title_name(wow_character)
  4. if wow_character.wow_character_title
  5. case wow_character.gender
  6. when 'FEMALE'
  7. wow_character.wow_character_title.female_name.gsub('{name}', wow_character.name)
  8. when 'MALE'
  9. wow_character.wow_character_title.male_name.gsub('{name}', wow_character.name)
  10. end
  11. else
  12. wow_character.name
  13. end
  14. end
  15. end

app/helpers/wow_classes_helper.rb

40.0% lines covered

5 relevant lines. 2 lines covered and 3 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowClassesHelper
  3. 1 def gender_class_name(gender, wow_class)
  4. case gender
  5. when 'FEMALE'
  6. wow_class.female_name
  7. when 'MALE'
  8. wow_class.male_name
  9. end
  10. end
  11. end

app/helpers/wow_mounts_helper.rb

66.67% lines covered

3 relevant lines. 2 lines covered and 1 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowMountsHelper
  3. 1 def mount_owned?(mount)
  4. mount.users.include? current_user
  5. end
  6. end

app/helpers/wow_pets_helper.rb

66.67% lines covered

3 relevant lines. 2 lines covered and 1 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowPetsHelper
  3. 1 def pet_owned?(pet)
  4. pet.users.include? current_user
  5. end
  6. end

app/helpers/wow_races_helper.rb

40.0% lines covered

5 relevant lines. 2 lines covered and 3 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowRacesHelper
  3. 1 def gender_race_name(gender, wow_race)
  4. case gender
  5. when 'FEMALE'
  6. wow_race.female_name
  7. when 'MALE'
  8. wow_race.male_name
  9. end
  10. end
  11. end

app/helpers/wow_reputations_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowReputationsHelper
  3. end

app/helpers/wow_standings_helper.rb

22.22% lines covered

9 relevant lines. 2 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module WowStandingsHelper
  3. 1 def reput_pourcentage(standing, tier)
  4. max = tier.max_value
  5. min = tier.min_value
  6. value = standing.value
  7. return 100 if max == min
  8. return value * 100 / (max - min) if max.positive? && (min.positive? || min.zero?)
  9. return value * -100 / (min - max) if min.negative? && (max.negative? || max.zero?)
  10. 0
  11. end
  12. end

app/jobs/application_job.rb

0.0% lines covered

2 relevant lines. 0 lines covered and 2 lines missed.
    
  1. # frozen_string_literal: true
  2. class ApplicationJob < ActiveJob::Base
  3. # Automatically retry jobs that encountered a deadlock
  4. # retry_on ActiveRecord::Deadlocked
  5. # Most jobs are safe to ignore if the underlying records are no longer available
  6. # discard_on ActiveJob::DeserializationError
  7. end

app/mailers/application_mailer.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. class ApplicationMailer < ActionMailer::Base
  3. default from: 'from@example.com'
  4. layout 'mailer'
  5. end

app/models/application_record.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 class ApplicationRecord < ActiveRecord::Base
  3. 1 self.abstract_class = true
  4. end

app/models/learned_wow_pet_ability.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. class LearnedWowPetAbility < ApplicationRecord
  3. belongs_to :wow_pet
  4. belongs_to :wow_pet_ability
  5. end

app/models/rp_world.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class RpWorld < ApplicationRecord
  3. belongs_to :user
  4. alias_attribute :owner, :user
  5. has_many :wow_character_play_rp_worlds, dependent: :destroy
  6. has_many :wow_characters, through: :wow_character_play_rp_worlds
  7. alias_attribute :members, :wow_characters
  8. validates :name, presence: true
  9. end

app/models/user.rb

45.45% lines covered

22 relevant lines. 10 lines covered and 12 lines missed.
    
  1. # frozen_string_literal: true
  2. # Model: User
  3. #
  4. # Description: Define an application user. the only authentication mecanism
  5. # is omniauthable with the BattleNet API
  6. 1 class User < ApplicationRecord
  7. 1 devise :rememberable, :omniauthable, omniauth_providers: [:bnet]
  8. 1 has_many :wow_characters, dependent: :destroy
  9. 1 has_many :user_obtain_wow_mounts, dependent: :destroy
  10. 1 has_many :wow_mounts, through: :user_obtain_wow_mounts
  11. 1 has_many :user_obtain_wow_pets, dependent: :destroy
  12. 1 has_many :wow_pets, through: :user_obtain_wow_pets
  13. 1 validates :battletag, presence: true, uniqueness: true
  14. 1 def self.from_omniauth(auth)
  15. user = User.where(provider: auth.provider, uid: auth.uid).first_or_initialize
  16. user.provider = auth.provider
  17. user.uid = auth.uid
  18. user.battletag = auth.info.battletag
  19. user.token_expires = auth.credentials.expires
  20. user.token_expire_at = Time.at(auth.credentials.expires_at).utc
  21. user.token = auth.credentials.token
  22. user.save
  23. user
  24. end
  25. 1 def self.new_with_session(params, session)
  26. super.tap do |user|
  27. if (data = session['devise.bnet_data']) && session['devise.bnet_data']['extra']['raw_info'] && user.email.blank?
  28. user.email = data['email']
  29. end
  30. end
  31. end
  32. end

app/models/user_obtain_wow_mount.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. class UserObtainWowMount < ApplicationRecord
  3. belongs_to :user
  4. belongs_to :wow_mount
  5. end

app/models/user_obtain_wow_pet.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. class UserObtainWowPet < ApplicationRecord
  3. belongs_to :user
  4. belongs_to :wow_pet
  5. end

app/models/wow_character.rb

0.0% lines covered

21 relevant lines. 0 lines covered and 21 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacter < ApplicationRecord
  3. extend Mobility
  4. translates :translated_faction, :translated_gender
  5. belongs_to :user
  6. belongs_to :wow_realm
  7. belongs_to :wow_class
  8. belongs_to :wow_race
  9. belongs_to :wow_character_title, optional: true
  10. belongs_to :wow_guild, optional: true
  11. has_one :wow_covenant_progress, dependent: :destroy
  12. has_one :wow_covenant, through: :wow_covenant_progress
  13. belongs_to :last_position, class_name: 'WowGeoPosition', optional: true
  14. belongs_to :bind_position, class_name: 'WowGeoPosition', optional: true
  15. has_one :wow_character_medium, dependent: :destroy
  16. has_many :wow_standings, dependent: :destroy
  17. has_many :wow_reputations, through: :wow_standings
  18. has_many :wow_character_play_rp_worlds, dependent: :destroy
  19. has_many :rp_worlds, through: :wow_character_play_rp_worlds
  20. validates :name, presence: true
  21. validates :character_id, presence: true, uniqueness: true
  22. end

app/models/wow_character_medium.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterMedium < ApplicationRecord
  3. belongs_to :wow_character
  4. end

app/models/wow_character_play_rp_world.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterPlayRpWorld < ApplicationRecord
  3. belongs_to :wow_character
  4. belongs_to :rp_world
  5. validates :status, presence: true, format: { with: /(INVITED|PENDING|PLAYING|BANNED)/ }
  6. validates :role, presence: true, format: { with: /(PLAYER|MODERATOR|ADMIN)/ }
  7. end

app/models/wow_character_title.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterTitle < ApplicationRecord
  3. extend Mobility
  4. translates :name, :male_name, :female_name
  5. has_many :wow_characters, dependent: :nullify
  6. validates :name, presence: true
  7. validates :title_id, presence: true, uniqueness: true
  8. end

app/models/wow_class.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowClass < ApplicationRecord
  3. extend Mobility
  4. translates :name, :power_type, :male_name, :female_name
  5. has_many :wow_characters, dependent: :nullify
  6. validates :name, presence: true
  7. validates :class_id, presence: true, uniqueness: true
  8. end

app/models/wow_covenant.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCovenant < ApplicationRecord
  3. extend Mobility
  4. translates :name, :description
  5. has_many :wow_covenant_progresses, dependent: :nullify
  6. has_many :wow_characters, through: :wow_covenant_progresses
  7. validates :name, presence: true
  8. validates :covenant_id, presence: true, uniqueness: true
  9. end

app/models/wow_covenant_progress.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCovenantProgress < ApplicationRecord
  3. belongs_to :wow_character
  4. belongs_to :wow_covenant
  5. end

app/models/wow_creature.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCreature < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. belongs_to :wow_creature_family, optional: true
  6. belongs_to :wow_creature_type, optional: true
  7. validates :name, presence: true
  8. validates :creature_id, presence: true, uniqueness: true
  9. end

app/models/wow_creature_family.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCreatureFamily < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_creatures, dependent: :destroy
  6. validates :name, presence: true
  7. validates :creature_family_id, presence: true, uniqueness: true
  8. end

app/models/wow_creature_type.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCreatureType < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_creatures, dependent: :destroy
  6. validates :name, presence: true
  7. validates :creature_type_id, presence: true, uniqueness: true
  8. end

app/models/wow_geo_map.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowGeoMap < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_geo_positions, dependent: :destroy
  6. validates :name, presence: true
  7. validates :map_id, presence: true, uniqueness: true
  8. end

app/models/wow_geo_position.rb

0.0% lines covered

18 relevant lines. 0 lines covered and 18 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowGeoPosition < ApplicationRecord
  3. belongs_to :wow_geo_map
  4. belongs_to :wow_geo_zone
  5. has_one(
  6. :last_position_character,
  7. class_name: 'WowCharacter',
  8. foreign_key: 'last_position_id',
  9. inverse_of: :last_position,
  10. dependent: :destroy
  11. )
  12. has_one(
  13. :bind_position_character,
  14. class_name: 'WowCharacter',
  15. foreign_key: 'bind_position_id',
  16. inverse_of: :bind_position,
  17. dependent: :destroy
  18. )
  19. end

app/models/wow_geo_zone.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowGeoZone < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_geo_positions, dependent: :destroy
  6. validates :name, presence: true
  7. validates :zone_id, presence: true, uniqueness: true
  8. end

app/models/wow_guild.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowGuild < ApplicationRecord
  3. extend Mobility
  4. translates :translated_faction
  5. belongs_to :wow_realm
  6. has_many :wow_characters, dependent: :nullify
  7. validates :name, presence: true
  8. validates :guild_id, presence: true, uniqueness: true
  9. end

app/models/wow_item.rb

0.0% lines covered

10 relevant lines. 0 lines covered and 10 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItem < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. belongs_to :wow_item_class
  6. belongs_to :wow_item_sub_class
  7. belongs_to :wow_item_inventory_type
  8. belongs_to :wow_item_quality
  9. validates :name, presence: true
  10. validates :item_id, presence: true, uniqueness: true
  11. end

app/models/wow_item_class.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemClass < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_item_sub_classes, dependent: :destroy
  6. has_many :wow_items, dependent: :destroy
  7. validates :name, presence: true
  8. validates :item_class_id, presence: true, uniqueness: true
  9. end

app/models/wow_item_inventory_type.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemInventoryType < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_items, dependent: :destroy
  6. validates :name, presence: true
  7. validates :item_inventory_type, presence: true, uniqueness: true
  8. end

app/models/wow_item_quality.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemQuality < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. has_many :wow_items, dependent: :destroy
  6. validates :name, presence: true
  7. validates :item_quality_type, presence: true, uniqueness: true
  8. end

app/models/wow_item_sub_class.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemSubClass < ApplicationRecord
  3. extend Mobility
  4. translates :display_name, :verbose_name
  5. belongs_to :wow_item_class
  6. has_many :wow_items, dependent: :destroy
  7. validates :item_sub_class_id, presence: true, uniqueness: { scope: :wow_item_class }
  8. end

app/models/wow_mount.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowMount < ApplicationRecord
  3. extend Mobility
  4. translates :name, :description, :translated_faction, :translated_source
  5. has_many :user_obtain_wow_mounts, dependent: :destroy
  6. has_many :users, through: :user_obtain_wow_mounts
  7. validates :name, presence: true
  8. validates :mount_id, presence: true, uniqueness: true
  9. end

app/models/wow_pet.rb

0.0% lines covered

10 relevant lines. 0 lines covered and 10 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPet < ApplicationRecord
  3. extend Mobility
  4. translates :name, :translated_battle_pet_type, :description, :translated_source_type
  5. has_many :learned_wow_pet_abilities, dependent: :destroy
  6. has_many :wow_pet_abilities, through: :learned_wow_pet_abilities
  7. has_many :user_obtain_wow_pets, dependent: :destroy
  8. has_many :users, through: :user_obtain_wow_pets
  9. validates :name, presence: true
  10. validates :pet_id, presence: true, uniqueness: true
  11. end

app/models/wow_pet_ability.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetAbility < ApplicationRecord
  3. extend Mobility
  4. translates :name, :translated_battle_pet_type
  5. has_many :learned_wow_pet_abilities, dependent: :destroy
  6. has_many :wow_pets, through: :learned_wow_pet_abilities
  7. validates :name, presence: true
  8. validates :ability_id, presence: true, uniqueness: true
  9. end

app/models/wow_race.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 class WowRace < ApplicationRecord
  3. 1 extend Mobility
  4. 1 translates :name, :translated_faction, :male_name, :female_name
  5. 1 has_many :wow_characters, dependent: :nullify
  6. 1 validates :name, presence: true
  7. 1 validates :race_id, presence: true, uniqueness: true
  8. end

app/models/wow_realm.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowRealm < ApplicationRecord
  3. extend Mobility
  4. translates :name, :category, :realm_type
  5. has_many :wow_characters, dependent: :nullify
  6. validates :name, presence: true
  7. validates :slug, presence: true
  8. validates :realm_id, presence: true, uniqueness: true
  9. end

app/models/wow_reputation.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputation < ApplicationRecord
  3. extend Mobility
  4. translates :name, :description, :translated_faction
  5. has_many :wow_standings, dependent: :destroy
  6. has_many :wow_characters, through: :wow_standings
  7. belongs_to :wow_reputation_tier, optional: true
  8. has_many :sub_wow_reputations,
  9. class_name: 'WowReputation',
  10. foreign_key: 'meta_wow_reputation_id',
  11. dependent: :nullify,
  12. inverse_of: :meta_wow_reputation
  13. belongs_to :meta_wow_reputation, class_name: 'WowReputation', optional: true
  14. validates :name, presence: true
  15. validates :reputation_id, presence: true, uniqueness: true
  16. scope :meta_reputations, -> { where(description: nil) }
  17. scope :non_meta_reputations, -> { where.not(description: nil) }
  18. end

app/models/wow_reputation_tier.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationTier < ApplicationRecord
  3. has_many :wow_reputations, dependent: :nullify
  4. has_many :wow_reputation_tier_levels, dependent: :destroy
  5. validates :reputation_tier_id, presence: true, uniqueness: true
  6. end

app/models/wow_reputation_tier_level.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationTierLevel < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. belongs_to :wow_reputation_tier
  6. validates :name, presence: true
  7. validates :order, presence: true, uniqueness: { scope: :wow_reputation_tier }
  8. default_scope { order(:order) }
  9. end

app/models/wow_spell.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowSpell < ApplicationRecord
  3. extend Mobility
  4. translates :name, :description
  5. validates :name, presence: true
  6. validates :spell_id, presence: true, uniqueness: true
  7. end

app/models/wow_standing.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowStanding < ApplicationRecord
  3. extend Mobility
  4. translates :name
  5. belongs_to :wow_character
  6. belongs_to :wow_reputation
  7. end

app/workers/wow_character_detail_worker.rb

0.0% lines covered

34 relevant lines. 0 lines covered and 34 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterDetailWorker < WowSidekiqWorker
  3. def perform(wow_character_id)
  4. return unless (wow_character = WowCharacter.find_by(character_id: wow_character_id))
  5. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  6. RBattlenet.set_options(locale: 'en_GB')
  7. # Public data
  8. params = {
  9. name: wow_character.name.downcase,
  10. realm: wow_character.wow_realm.slug
  11. }
  12. result = RBattlenet::Wow::Character.find(params)
  13. return unless result.status_code == 200
  14. wow_character.achievements_points = result.achievement_points
  15. wow_character.last_login_timestamp = Time.at(result.last_login_timestamp.to_s[0..-4].to_i).utc
  16. wow_character.average_item_level = result.average_item_level
  17. wow_character.equipped_item_level = result.equipped_item_level
  18. wow_character.wow_character_title = WowCharacterTitle.find_by(title_id: result.active_title.id) if result.active_title
  19. wow_character.wow_guild = find_or_create_wow_guild(result.guild) if result.guild
  20. wow_character.save
  21. update_covenant_progress(wow_character, result.covenant_progress) if result.covenant_progress
  22. end
  23. def find_or_create_wow_guild(guild)
  24. wow_guild = WowGuild.find_or_initialize_by(guild_id: guild.id)
  25. wow_guild.name = guild.name
  26. wow_guild.wow_realm = WowRealm.find_by(realm_id: guild.realm.id)
  27. wow_guild.save
  28. wow_guild.persisted? ? wow_guild : nil
  29. end
  30. def update_covenant_progress(wow_character, covenant_progress)
  31. wow_covenant_progress = wow_character.wow_covenant_progress || WowCovenantProgress.new(wow_character: wow_character)
  32. wow_covenant_progress.renown_level = covenant_progress.renown_level
  33. wow_covenant_progress.wow_covenant = WowCovenant.find_by(covenant_id: covenant_progress.chosen_covenant.id)
  34. wow_covenant_progress.save
  35. end
  36. end

app/workers/wow_character_media_worker.rb

0.0% lines covered

26 relevant lines. 0 lines covered and 26 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterMediaWorker < WowSidekiqWorker
  3. def perform(wow_character_id)
  4. return unless (wow_character = WowCharacter.where(character_id: wow_character_id).first)
  5. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  6. RBattlenet.set_options(locale: 'en_GB')
  7. result = RBattlenet::Wow::Character::Media.find({ name: wow_character.name.downcase, realm: wow_character.wow_realm.slug })
  8. return unless result.status_code == 200
  9. return unless (wow_character_media = wow_character.wow_character_medium || WowCharacterMedium.new)
  10. wow_character_media.wow_character = wow_character
  11. wow_character_media.href = result._links.self.href
  12. return unless result.assets
  13. result.assets.each do |asset|
  14. case asset['key']
  15. when 'avatar'
  16. wow_character_media.avatar = asset['value']
  17. when 'inset'
  18. wow_character_media.inset = asset['value']
  19. when 'main'
  20. wow_character_media.main = asset['value']
  21. when 'main-raw'
  22. wow_character_media.main_raw = asset['value']
  23. end
  24. end
  25. wow_character_media.save
  26. end
  27. end

app/workers/wow_character_positions_worker.rb

0.0% lines covered

54 relevant lines. 0 lines covered and 54 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterPositionsWorker < WowSidekiqWorker
  3. def perform(wow_character_id)
  4. return unless (wow_character = WowCharacter.find_by(character_id: wow_character_id))
  5. # Protected data
  6. RBattlenet.set_options(locale: 'all')
  7. params = {
  8. character_id: wow_character_id,
  9. realm_id: wow_character.wow_realm.realm_id,
  10. token: wow_character.user.token
  11. }
  12. result = RBattlenet::Wow::Profile::ProtectedSummary.find(params)
  13. return unless result.status_code == 200
  14. if (last_position = result.position)
  15. wow_character_last_position = wow_character.last_position || WowGeoPosition.new(last_position_character: wow_character)
  16. wow_character_last_position.wow_geo_zone = find_or_create_wow_geo_zone(last_position.zone)
  17. wow_character_last_position.wow_geo_map = find_or_create_wow_geo_map(last_position.map)
  18. wow_character_last_position.x = last_position.x
  19. wow_character_last_position.y = last_position.y
  20. wow_character_last_position.z = last_position.z
  21. wow_character_last_position.facing = last_position.facing
  22. wow_character_last_position.save
  23. end
  24. if (bind_position = result.bind_position)
  25. wow_character_bind_position = wow_character.bind_position || WowGeoPosition.new(bind_position_character: wow_character)
  26. wow_character_bind_position.wow_geo_zone = find_or_create_wow_geo_zone(bind_position.zone)
  27. wow_character_bind_position.wow_geo_map = find_or_create_wow_geo_map(bind_position.map)
  28. wow_character_bind_position.x = bind_position.x
  29. wow_character_bind_position.y = bind_position.y
  30. wow_character_bind_position.z = bind_position.z
  31. wow_character_bind_position.facing = bind_position.facing
  32. wow_character_bind_position.save
  33. end
  34. end
  35. private
  36. def find_or_create_wow_geo_zone(zone)
  37. wow_geo_zone = WowGeoZone.find_or_initialize_by(zone_id: zone.id)
  38. locales.each do |locale|
  39. Mobility.with_locale(locale[0]) do
  40. wow_geo_zone.name = zone.name[locale[1]]
  41. end
  42. end
  43. wow_geo_zone.save
  44. wow_geo_zone.persisted? ? wow_geo_zone : nil
  45. end
  46. def find_or_create_wow_geo_map(map)
  47. wow_geo_map = WowGeoMap.find_or_initialize_by(map_id: map.id)
  48. locales.each do |locale|
  49. Mobility.with_locale(locale[0]) do
  50. wow_geo_map.name = map.name[locale[1]]
  51. end
  52. end
  53. wow_geo_map.save
  54. wow_geo_map.persisted? ? wow_geo_map : nil
  55. end
  56. end

app/workers/wow_character_title_detail_worker.rb

0.0% lines covered

15 relevant lines. 0 lines covered and 15 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterTitleDetailWorker < WowSidekiqWorker
  3. def perform(title_id)
  4. return unless (title = WowCharacterTitle.where(title_id: title_id).first)
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Title.find(title_id)
  7. return unless result.status_code == 200
  8. # Localisation data
  9. locales.each do |locale|
  10. Mobility.with_locale(locale[0]) do
  11. title.male_name = result.gender_name.male[locale[1]]
  12. title.female_name = result.gender_name.female[locale[1]]
  13. end
  14. end
  15. title.save
  16. end
  17. end

app/workers/wow_character_titles_worker.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharacterTitlesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Title.all
  7. return unless result.status_code == 200
  8. result.titles.each do |title|
  9. wow_title = WowCharacterTitle.find_or_initialize_by(title_id: title.id)
  10. wow_title.href = title.key.href
  11. # Localisation data
  12. locales.each do |locale|
  13. Mobility.with_locale(locale[0]) { wow_title.name = title.name[locale[1]] }
  14. end
  15. wow_title.save
  16. WowCharacterTitleDetailWorker.perform_async(wow_title.title_id) if wow_title.persisted?
  17. end
  18. end
  19. end

app/workers/wow_characters_worker.rb

0.0% lines covered

35 relevant lines. 0 lines covered and 35 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCharactersWorker < WowSidekiqWorker
  3. def perform(user_id)
  4. # Update the WoW character list
  5. return unless (user = User.find(user_id))
  6. RBattlenet.set_options(locale: 'all')
  7. result = RBattlenet::Wow::Profile::User.find(user.token)
  8. return unless result.status_code == 200
  9. result.wow_accounts.each do |account|
  10. account.characters.each do |character|
  11. wow_char = user.wow_characters.find_or_initialize_by(character_id: character.id)
  12. wow_char.name = character.name
  13. wow_char.gender = character.gender.type
  14. wow_char.faction = character.faction.type
  15. wow_char.href = character.character.href
  16. wow_char.level = character.level
  17. wow_char.wow_realm = WowRealm.where(realm_id: character.realm.id).first
  18. wow_char.wow_class = WowClass.where(class_id: character.playable_class.id).first
  19. wow_char.wow_race = WowRace.where(race_id: character.playable_race.id).first
  20. wow_char.user = user
  21. wow_char.account_id = account.id
  22. locales.each do |locale|
  23. Mobility.with_locale(locale[0]) do
  24. wow_char.translated_faction = character.faction.name[locale[1]]
  25. wow_char.translated_gender = character.gender.name[locale[1]]
  26. end
  27. end
  28. wow_char.save
  29. next unless wow_char.persisted?
  30. WowCharacterMediaWorker.perform_async(wow_char.character_id)
  31. WowCharacterDetailWorker.perform_async(wow_char.character_id)
  32. WowCharacterPositionsWorker.perform_async(wow_char.character_id)
  33. WowStandingWorker.perform_async(wow_char.character_id)
  34. end
  35. end
  36. end
  37. end

app/workers/wow_class_detail_worker.rb

0.0% lines covered

16 relevant lines. 0 lines covered and 16 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowClassDetailWorker < WowSidekiqWorker
  3. def perform(class_id)
  4. return unless (wow_class = WowClass.find_by(class_id: class_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::PlayableClass.find(class_id)
  7. return unless result.status_code == 200
  8. # Localisation data
  9. locales.each do |locale|
  10. Mobility.with_locale(locale[0]) do
  11. wow_class.power_type = result.power_type.name[locale[1]]
  12. wow_class.male_name = result.gender_name.male[locale[1]]
  13. wow_class.female_name = result.gender_name.female[locale[1]]
  14. end
  15. end
  16. wow_class.save
  17. end
  18. end

app/workers/wow_classes_worker.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowClassesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::PlayableClass.all
  7. return unless result.status_code == 200
  8. result.classes.each do |playable_class|
  9. wow_class = WowClass.find_or_initialize_by(class_id: playable_class.id)
  10. wow_class.href = playable_class.key.href
  11. # Localisation data
  12. locales.each do |locale|
  13. Mobility.with_locale(locale[0]) { wow_class.name = playable_class.name[locale[1]] }
  14. end
  15. wow_class.save
  16. WowClassDetailWorker.perform_async(wow_class.class_id) if wow_class.persisted?
  17. end
  18. end
  19. end

app/workers/wow_covenant_detail_worker.rb

0.0% lines covered

15 relevant lines. 0 lines covered and 15 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCovenantDetailWorker < WowSidekiqWorker
  3. def perform(covenant_id)
  4. return unless (wow_covenant = WowCovenant.find_by(covenant_id: covenant_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Covenant.find(covenant_id)
  7. return unless result.status_code == 200
  8. wow_covenant.media_id = result.media.id
  9. # Localisation data
  10. locales.each do |locale|
  11. Mobility.with_locale(locale[0]) do
  12. wow_covenant.description = result.description[locale[1]]
  13. end
  14. end
  15. wow_covenant.save
  16. end
  17. end

app/workers/wow_covenants_worker.rb

0.0% lines covered

16 relevant lines. 0 lines covered and 16 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCovenantsWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Covenant.all
  7. return unless result.status_code == 200
  8. result.covenants.each do |covenant|
  9. wow_covenant = WowCovenant.find_or_initialize_by(covenant_id: covenant.id)
  10. # Localisation data
  11. locales.each do |locale|
  12. Mobility.with_locale(locale[0]) { wow_covenant.name = covenant.name[locale[1]] }
  13. end
  14. wow_covenant.save
  15. WowCovenantDetailWorker.perform_async(wow_covenant.covenant_id) if wow_covenant.persisted?
  16. end
  17. end
  18. end

app/workers/wow_creature_families_worker.rb

0.0% lines covered

15 relevant lines. 0 lines covered and 15 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCreatureFamiliesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::CreatureFamily.all
  7. return unless result.status_code == 200
  8. result.creature_families.each do |creature_family|
  9. wow_creature_family = WowCreatureFamily.find_or_initialize_by(creature_family_id: creature_family.id)
  10. # Localisation data
  11. locales.each do |locale|
  12. Mobility.with_locale(locale[0]) { wow_creature_family.name = creature_family.name[locale[1]] }
  13. end
  14. wow_creature_family.save
  15. end
  16. end
  17. end

app/workers/wow_creature_types_worker.rb

0.0% lines covered

15 relevant lines. 0 lines covered and 15 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCreatureTypesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::CreatureType.all
  7. return unless result.status_code == 200
  8. result.creature_types.each do |creature_type|
  9. wow_creature_type = WowCreatureType.find_or_initialize_by(creature_type_id: creature_type.id)
  10. # Localisation data
  11. locales.each do |locale|
  12. Mobility.with_locale(locale[0]) { wow_creature_type.name = creature_type.name[locale[1]] }
  13. end
  14. wow_creature_type.save
  15. end
  16. end
  17. end

app/workers/wow_creatures_worker.rb

0.0% lines covered

29 relevant lines. 0 lines covered and 29 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowCreaturesWorker < WowSidekiqWorker
  3. def perform(creature_id, batch_size, keep_going_on)
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. params = {
  7. _page: 1,
  8. _pageSize: batch_size,
  9. orderby: 'id',
  10. filters: { id: "[#{creature_id},]" }
  11. }
  12. result = RBattlenet::Wow::Search::Creature.find(params)
  13. return unless result.status_code == 200
  14. result.results&.each do |creature|
  15. wow_creature = WowCreature.find_or_initialize_by(creature_id: creature.data.id)
  16. wow_creature.display_id = creature.data.creature_displays&.first&.id
  17. wow_creature.is_tameable = creature.data&.is_tameable
  18. wow_creature.wow_creature_family = WowCreatureFamily.find_by(creature_family_id: creature.data.family.id) if creature.data.family
  19. wow_creature.wow_creature_type = WowCreatureType.find_by(creature_type_id: creature.data.type.id) if creature.data.type
  20. # Localisation data
  21. locales.each do |locale|
  22. Mobility.with_locale(locale[0]) do
  23. wow_creature.name = creature.data.name[locale[1]]
  24. end
  25. end
  26. wow_creature.save
  27. end
  28. # Create a new job for the next batch if keep_going_on is true
  29. return unless keep_going_on && !result.results.count.zero?
  30. WowCreaturesWorker.perform_async(result.results.last.data.id + 1, batch_size, keep_going_on)
  31. end
  32. end

app/workers/wow_guild_detail_worker.rb

0.0% lines covered

22 relevant lines. 0 lines covered and 22 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowGuildDetailWorker < WowSidekiqWorker
  3. def perform(wow_guild_id)
  4. return unless (wow_guild = WowGuild.find_by(guild_id: wow_guild_id))
  5. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  6. RBattlenet.set_options(locale: 'all')
  7. # Public data
  8. params = {
  9. name: wow_guild.name.downcase.tr(' ', '-'),
  10. realm: wow_guild.wow_realm.slug
  11. }
  12. result = RBattlenet::Wow::Guild.find(params)
  13. return unless result.status_code == 200
  14. wow_guild.achievement_points = result.achievement_points
  15. wow_guild.member_count = result.member_count
  16. wow_guild.faction = result.faction.type
  17. # Localisation data
  18. locales.each do |locale|
  19. Mobility.with_locale(locale[0]) do
  20. wow_guild.translated_faction = result.faction.name[locale[1]]
  21. end
  22. end
  23. wow_guild.save
  24. end
  25. end

app/workers/wow_item_class_detail_worker.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemClassDetailWorker < WowSidekiqWorker
  3. def perform(item_class_id)
  4. return unless (wow_item_class = WowItemClass.find_by(item_class_id: item_class_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::ItemClass.find(item_class_id)
  7. return unless result.status_code == 200
  8. result.item_subclasses.each do |item_subclass|
  9. wow_item_sub_class = wow_item_class.wow_item_sub_classes.create_with(wow_item_class: wow_item_class).find_or_create_by(item_sub_class_id: item_subclass.id)
  10. WowItemSubClassDetailWorker.perform_async(wow_item_class.item_class_id, wow_item_sub_class.item_sub_class_id) if wow_item_sub_class.persisted?
  11. end
  12. end
  13. end

app/workers/wow_item_classes_worker.rb

0.0% lines covered

16 relevant lines. 0 lines covered and 16 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemClassesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::ItemClass.all
  7. return unless result.status_code == 200
  8. result.item_classes.each do |item_class|
  9. wow_item_class = WowItemClass.find_or_initialize_by(item_class_id: item_class.id)
  10. # Localisation data
  11. locales.each do |locale|
  12. Mobility.with_locale(locale[0]) { wow_item_class.name = item_class.name[locale[1]] }
  13. end
  14. wow_item_class.save
  15. WowItemClassDetailWorker.perform_async(wow_item_class.item_class_id) if wow_item_class.persisted?
  16. end
  17. end
  18. end

app/workers/wow_item_sub_class_detail_worker.rb

0.0% lines covered

19 relevant lines. 0 lines covered and 19 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemSubClassDetailWorker < WowSidekiqWorker
  3. def perform(item_class_id, item_sub_class_id)
  4. return unless (wow_item_sub_class = WowItemSubClass.joins(:wow_item_class).where(item_sub_class_id: item_sub_class_id, wow_item_class: { item_class_id: item_class_id }).first)
  5. RBattlenet.set_options(locale: 'all')
  6. params = {
  7. class_id: item_class_id,
  8. id: item_sub_class_id
  9. }
  10. result = RBattlenet::Wow::ItemSubclass.find(params)
  11. return unless result.status_code == 200
  12. # Localisation data
  13. locales.each do |locale|
  14. Mobility.with_locale(locale[0]) do
  15. wow_item_sub_class.display_name = result.display_name[locale[1]] if result.display_name
  16. wow_item_sub_class.verbose_name = result.verbose_name[locale[1]] if result.verbose_name
  17. end
  18. end
  19. wow_item_sub_class.save
  20. end
  21. end

app/workers/wow_items_worker.rb

0.0% lines covered

58 relevant lines. 0 lines covered and 58 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowItemsWorker < WowSidekiqWorker
  3. def perform(item_id, batch_size, keep_going_on)
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. params = {
  7. _page: 1,
  8. _pageSize: batch_size,
  9. orderby: 'id',
  10. filters: { id: "[#{item_id},]" }
  11. }
  12. result = RBattlenet::Wow::Search::Item.find(params)
  13. return unless result.status_code == 200
  14. result.results&.each do |item|
  15. wow_item = WowItem.find_or_initialize_by(item_id: item.data.id)
  16. wow_item.level = item.data.level if item.data.level
  17. wow_item.required_level = item.data.required_level if item.data.required_level
  18. wow_item.sell_price = item.data.sell_price if item.data.sell_price
  19. wow_item.purchase_price = item.data.purchase_price if item.data.purchase_price
  20. wow_item.is_equippable = item.data.is_equippable if item.data.is_equippable
  21. wow_item.is_stackable = item.data.is_stackable if item.data.is_stackable
  22. wow_item.media_id = item.data.media.id if item.data.media.id
  23. wow_item.max_count = item.data.max_count if item.data.max_count
  24. wow_item.wow_item_class = WowItemClass.find_by(item_class_id: item.data.item_class.id)
  25. wow_item.wow_item_sub_class = WowItemSubClass.joins(:wow_item_class).where(item_sub_class_id: item.data.item_subclass.id, wow_item_class: { item_class_id: item.data.item_class.id }).first
  26. wow_item.wow_item_quality = find_or_create_wow_item_quality(item.data.quality)
  27. wow_item.wow_item_inventory_type = find_or_create_wow_item_inventory_type(item.data.inventory_type)
  28. # Localisation data
  29. locales.each do |locale|
  30. Mobility.with_locale(locale[0]) do
  31. wow_item.name = item.data.name[locale[1]]
  32. end
  33. end
  34. wow_item.save
  35. end
  36. # Create a new job for the next batch if keep_going_on is true
  37. return unless keep_going_on && !result.results.count.zero?
  38. WowItemsWorker.perform_async(result.results.last.data.id + 1, batch_size, keep_going_on)
  39. end
  40. private
  41. def find_or_create_wow_item_quality(item_quality)
  42. wow_item_quality = WowItemQuality.find_or_initialize_by(item_quality_type: item_quality.type)
  43. # Localisation data
  44. locales.each do |locale|
  45. Mobility.with_locale(locale[0]) do
  46. wow_item_quality.name = item_quality.name[locale[1]]
  47. end
  48. end
  49. wow_item_quality.save
  50. wow_item_quality.persisted? ? wow_item_quality : nil
  51. end
  52. def find_or_create_wow_item_inventory_type(item_inventory_type)
  53. wow_item_inventory_type = WowItemInventoryType.find_or_initialize_by(item_inventory_type: item_inventory_type.type)
  54. # Localisation data
  55. locales.each do |locale|
  56. Mobility.with_locale(locale[0]) do
  57. wow_item_inventory_type.name = item_inventory_type.name[locale[1]]
  58. end
  59. end
  60. wow_item_inventory_type.save
  61. wow_item_inventory_type.persisted? ? wow_item_inventory_type : nil
  62. end
  63. end

app/workers/wow_mount_detail_worker.rb

0.0% lines covered

21 relevant lines. 0 lines covered and 21 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowMountDetailWorker < WowSidekiqWorker
  3. def perform(mount_id)
  4. return unless (mount = WowMount.find_by(mount_id: mount_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Mount.find(mount_id)
  7. return unless result.status_code == 200
  8. mount.faction = result.faction.type if result.faction
  9. # Localisation data
  10. locales.each do |locale|
  11. Mobility.with_locale(locale[0]) do
  12. mount.translated_faction = result.faction.name[locale[1]] if result.faction
  13. mount.description = result.description[locale[1]]
  14. end
  15. end
  16. if result.creature_displays.first
  17. mount.creature_display_id = result.creature_displays.first.id
  18. media = RBattlenet::Wow::CreatureMedia.find(result.creature_displays.first.id)
  19. mount.asset_zoom = media.assets.find { |asset| asset['key'] == 'zoom' }.value || nil
  20. end
  21. mount.save
  22. end
  23. end

app/workers/wow_mounts_collection_worker.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowMountsCollectionWorker < WowSidekiqWorker
  3. def perform(user_id)
  4. return unless (user = User.find(user_id))
  5. RBattlenet.set_options(locale: 'en_US')
  6. result = RBattlenet::Wow::Profile::MountsCollection.find(user.token)
  7. return unless result.status_code == 200
  8. result.mounts.each do |mount|
  9. next unless (local_mount = WowMount.where(mount_id: mount.mount.id).first)
  10. UserObtainWowMount.where(user: user.id, wow_mount: local_mount.id).first_or_create
  11. end
  12. end
  13. end

app/workers/wow_mounts_worker.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowMountsWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Mount.all
  7. return unless result.status_code == 200
  8. result.mounts.each do |mount|
  9. wow_mount = WowMount.find_or_initialize_by(mount_id: mount.id)
  10. # Global data
  11. wow_mount.href = mount.key.href
  12. # Localisation data
  13. locales.each do |locale|
  14. Mobility.with_locale(locale[0]) { wow_mount.name = mount.name[locale[1]] }
  15. end
  16. wow_mount.save
  17. WowMountDetailWorker.perform_async(wow_mount.mount_id) if wow_mount.persisted?
  18. end
  19. end
  20. end

app/workers/wow_pet_abilities_worker.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetAbilitiesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::PetAbility.all
  7. return unless result.status_code == 200
  8. result.abilities.each do |ability|
  9. wow_pet_ability = WowPetAbility.find_or_initialize_by(ability_id: ability.id)
  10. wow_pet_ability.href = ability.key.href
  11. # Localisation data
  12. locales.each do |locale|
  13. Mobility.with_locale(locale[0]) { wow_pet_ability.name = ability.name[locale[1]] }
  14. end
  15. wow_pet_ability.save
  16. WowPetAbilityDetailWorker.perform_async(wow_pet_ability.ability_id) if wow_pet_ability.persisted?
  17. end
  18. end
  19. end

app/workers/wow_pet_ability_detail_worker.rb

0.0% lines covered

21 relevant lines. 0 lines covered and 21 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetAbilityDetailWorker < WowSidekiqWorker
  3. def perform(ability_id)
  4. return unless (ability = WowPetAbility.find_by(ability_id: ability_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::PetAbility.find(ability_id)
  7. return unless result.status_code == 200
  8. ability.battle_pet_type = result.battle_pet_type.type
  9. ability.battle_pet_type_id = result.battle_pet_type.id
  10. ability.rounds = result.rounds if result.rounds
  11. # Localisation data
  12. locales.each do |locale|
  13. Mobility.with_locale(locale[0]) do
  14. ability.translated_battle_pet_type = result.battle_pet_type.name[locale[1]]
  15. end
  16. end
  17. if result.media
  18. media = RBattlenet::Wow::PetAbilityMedia.find(result.media.id)
  19. ability.media = media.assets.find { |asset| asset['key'] == 'icon' }.value || nil
  20. end
  21. ability.save
  22. end
  23. end

app/workers/wow_pet_detail_worker.rb

0.0% lines covered

35 relevant lines. 0 lines covered and 35 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetDetailWorker < WowSidekiqWorker
  3. def perform(pet_id)
  4. return unless (pet = WowPet.find_by(pet_id: pet_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Pet.find(pet_id)
  7. return unless result.status_code == 200
  8. pet.is_capturable = result.is_capturable
  9. pet.is_battlepet = result.is_battlepet
  10. pet.is_alliance_only = result.is_alliance_only
  11. pet.is_horde_only = result.is_horde_only
  12. pet.is_capturable = result.is_capturable
  13. pet.is_random_creature_display = result.is_random_creature_display
  14. pet.icon = result.icon
  15. pet.creature_id = result.creature.id
  16. pet.battle_pet_type = result.battle_pet_type.type
  17. pet.battle_pet_type_id = result.battle_pet_type.id
  18. # Localisation data
  19. locales.each do |locale|
  20. Mobility.with_locale(locale[0]) do
  21. pet.translated_battle_pet_type = result.battle_pet_type.name[locale[1]]
  22. pet.description = result.description[locale[1]]
  23. end
  24. end
  25. unless pet.creature_display_id
  26. creature = RBattlenet::Wow::Creature.find(pet.creature_id)
  27. pet.creature_display_id = creature.creature_displays.first.id if creature.status_code == 200
  28. end
  29. creature_media = RBattlenet::Wow::CreatureMedia.find(pet.creature_display_id)
  30. pet.media_zoom_url = creature_media.assets.first.value if creature_media.status_code == 200
  31. result.abilities&.each do |ability|
  32. next unless (local_ability = WowPetAbility.where(ability_id: ability.ability.id).first)
  33. LearnedWowPetAbility.where(wow_pet: pet.id, wow_pet_ability: local_ability.id).first_or_create
  34. end
  35. pet.save
  36. end
  37. end

app/workers/wow_pets_collection_worker.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetsCollectionWorker < WowSidekiqWorker
  3. def perform(user_id)
  4. return unless (user = User.find(user_id))
  5. RBattlenet.set_options(locale: 'en_US')
  6. result = RBattlenet::Wow::Profile::PetsCollection.find(user.token)
  7. return unless result.status_code == 200
  8. result.pets.each do |pet|
  9. next unless (local_pet = WowPet.find_by(pet_id: pet.species.id))
  10. UserObtainWowPet.where(user: user.id, wow_pet: local_pet.id).first_or_create
  11. end
  12. end
  13. end

app/workers/wow_pets_worker.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowPetsWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Pet.all
  7. return unless result.status_code == 200
  8. result.pets.each do |pet|
  9. wow_pet = WowPet.find_or_initialize_by(pet_id: pet.id)
  10. # Global data
  11. wow_pet.href = pet.key.href
  12. # Localisation data
  13. locales.each do |locale|
  14. Mobility.with_locale(locale[0]) { wow_pet.name = pet.name[locale[1]] }
  15. end
  16. wow_pet.save
  17. WowPetDetailWorker.perform_async(wow_pet.pet_id) if wow_pet.persisted?
  18. end
  19. end
  20. end

app/workers/wow_race_detail_worker.rb

0.0% lines covered

19 relevant lines. 0 lines covered and 19 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowRaceDetailWorker < WowSidekiqWorker
  3. def perform(race_id)
  4. return unless (race = WowRace.find_by(race_id: race_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::PlayableRace.find(race_id)
  7. return unless result.status_code == 200
  8. race.faction = result.faction.type
  9. race.is_selectable = result.is_selectable
  10. race.is_allied_race = result.is_allied_race
  11. # Localisation data
  12. locales.each do |locale|
  13. Mobility.with_locale(locale[0]) do
  14. race.translated_faction = result.faction.name[locale[1]]
  15. race.male_name = result.gender_name.male[locale[1]]
  16. race.female_name = result.gender_name.female[locale[1]]
  17. end
  18. end
  19. race.save
  20. end
  21. end

app/workers/wow_races_worker.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowRacesWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::PlayableRace.all
  7. return unless result.status_code == 200
  8. result.races.each do |playable_race|
  9. wow_race = WowRace.find_or_initialize_by(race_id: playable_race.id)
  10. # Global data
  11. wow_race.href = playable_race.key.href
  12. # Localisation data
  13. locales.each do |locale|
  14. Mobility.with_locale(locale[0]) { wow_race.name = playable_race.name[locale[1]] }
  15. end
  16. wow_race.save
  17. WowRaceDetailWorker.perform_async(wow_race.race_id) if wow_race.persisted?
  18. end
  19. end
  20. end

app/workers/wow_realm_detail_worker.rb

0.0% lines covered

18 relevant lines. 0 lines covered and 18 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowRealmDetailWorker < WowSidekiqWorker
  3. def perform(realm_id)
  4. return unless (realm = WowRealm.find_by(realm_id: realm_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Realm.find(realm_id)
  7. return unless result.status_code == 200
  8. realm.locale = result.locale
  9. realm.timezone = result.timezone
  10. realm.is_tournament = result.is_tournament
  11. # Localisation data
  12. locales.each do |locale|
  13. Mobility.with_locale(locale[0]) do
  14. realm.realm_type = result.type.name[locale[1]]
  15. realm.category = result.category[locale[1]]
  16. end
  17. end
  18. realm.save
  19. end
  20. end

app/workers/wow_realms_worker.rb

0.0% lines covered

18 relevant lines. 0 lines covered and 18 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowRealmsWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::Realm.all
  7. return unless result.status_code == 200
  8. result.realms.each do |realm|
  9. wow_realm = WowRealm.find_or_initialize_by(realm_id: realm.id)
  10. wow_realm.slug = realm.slug
  11. wow_realm.href = realm.key.href
  12. # Localisation data
  13. locales.each do |locale|
  14. Mobility.with_locale(locale[0]) { wow_realm.name = realm.name[locale[1]] }
  15. end
  16. wow_realm.save
  17. WowRealmDetailWorker.perform_async(wow_realm.realm_id) if wow_realm.persisted?
  18. end
  19. end
  20. end

app/workers/wow_reputation_detail_worker.rb

0.0% lines covered

20 relevant lines. 0 lines covered and 20 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationDetailWorker < WowSidekiqWorker
  3. def perform(reputation_id)
  4. return unless (wow_reputation = WowReputation.find_by(reputation_id: reputation_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::ReputationFaction.find(reputation_id)
  7. return unless result.status_code == 200
  8. # Global data
  9. wow_reputation.wow_reputation_tier = WowReputationTier.find_by(reputation_tier_id: result.reputation_tiers.id)
  10. wow_reputation.faction = result.player_faction.type if result.player_faction
  11. # If it's a meta faction
  12. result.factions&.each do |faction|
  13. wow_reputation.sub_wow_reputations << WowReputation.find_by(reputation_id: faction.id)
  14. end
  15. # Localisation data
  16. locales.each do |locale|
  17. Mobility.with_locale(locale[0]) do
  18. wow_reputation.description = result.description[locale[1]] if result.description
  19. wow_reputation.translated_faction = result.player_faction.name[locale[1]] if result.player_faction
  20. end
  21. end
  22. wow_reputation.save
  23. end
  24. end

app/workers/wow_reputation_tier_detail_worker.rb

0.0% lines covered

22 relevant lines. 0 lines covered and 22 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationTierDetailWorker < WowSidekiqWorker
  3. def perform(reputation_tier_id)
  4. return unless (wow_reputation_tier = WowReputationTier.find_by(reputation_tier_id: reputation_tier_id))
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::ReputationTiers.find(reputation_tier_id)
  7. return unless result.status_code == 200
  8. result.tiers.each do |tier|
  9. reputation_tier_level = WowReputationTierLevel.where(wow_reputation_tier: wow_reputation_tier, order: tier.id).first_or_initialize
  10. reputation_tier_level.wow_reputation_tier = wow_reputation_tier
  11. reputation_tier_level.order = tier.id
  12. reputation_tier_level.min_value = tier.min_value
  13. reputation_tier_level.max_value = tier.max_value
  14. # Localisation data
  15. locales.each do |locale|
  16. Mobility.with_locale(locale[0]) do
  17. reputation_tier_level.name = tier.name[locale[1]]
  18. end
  19. end
  20. reputation_tier_level.save
  21. end
  22. wow_reputation_tier.save
  23. end
  24. end

app/workers/wow_reputation_tiers_worker.rb

0.0% lines covered

14 relevant lines. 0 lines covered and 14 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationTiersWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'en_US')
  6. result = RBattlenet::Wow::ReputationTiers.all
  7. return unless result.status_code == 200
  8. result.reputation_tiers.each do |reputation_tier|
  9. wow_reputation_tier = WowReputationTier.find_or_initialize_by(reputation_tier_id: reputation_tier.id)
  10. # Global data
  11. wow_reputation_tier.href = reputation_tier.key.href
  12. wow_reputation_tier.save
  13. WowReputationTierDetailWorker.perform_async(wow_reputation_tier.reputation_tier_id) if wow_reputation_tier.persisted?
  14. end
  15. end
  16. end

app/workers/wow_reputations_worker.rb

0.0% lines covered

19 relevant lines. 0 lines covered and 19 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowReputationsWorker < WowSidekiqWorker
  3. def perform
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. result = RBattlenet::Wow::ReputationFaction.all
  7. return unless result.status_code == 200
  8. result.factions.each do |faction|
  9. wow_reputation = WowReputation.find_or_initialize_by(reputation_id: faction.id)
  10. # Global data
  11. wow_reputation.href = faction.key.href
  12. # Localisation data
  13. locales.each do |locale|
  14. Mobility.with_locale(locale[0]) do
  15. wow_reputation.name = faction.name[locale[1]]
  16. end
  17. end
  18. wow_reputation.save
  19. WowReputationDetailWorker.perform_async(wow_reputation.reputation_id) if wow_reputation.persisted?
  20. end
  21. end
  22. end

app/workers/wow_sidekiq_worker.rb

0.0% lines covered

19 relevant lines. 0 lines covered and 19 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowSidekiqWorker
  3. include Sidekiq::Worker
  4. def locales
  5. [
  6. ['en-us', 'en_US'],
  7. ['es-mx', 'es_MX'],
  8. ['pt-br', 'pt_BR'],
  9. ['de-de', 'de_DE'],
  10. ['en-gb', 'en_GB'],
  11. ['es-es', 'es_ES'],
  12. ['fr-fr', 'fr_FR'],
  13. ['it', 'it_IT'],
  14. ['ru-ru', 'ru_RU'],
  15. ['ko', 'ko_KR'],
  16. ['zh-tw', 'zh_TW'],
  17. ['zh-cn', 'zh_CN']
  18. ]
  19. end
  20. end

app/workers/wow_spells_worker.rb

0.0% lines covered

26 relevant lines. 0 lines covered and 26 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowSpellsWorker < WowSidekiqWorker
  3. def perform(spell_id, batch_size, keep_going_on)
  4. RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
  5. RBattlenet.set_options(locale: 'all')
  6. params = {
  7. _page: 1,
  8. _pageSize: batch_size,
  9. orderby: 'id',
  10. filters: { id: "[#{spell_id},]" }
  11. }
  12. result = RBattlenet::Wow::Search::Spell.find(params)
  13. return unless result.status_code == 200
  14. result.results&.each do |spell|
  15. wow_spell = WowSpell.find_or_initialize_by(spell_id: spell.data.id)
  16. wow_spell.media_id = spell.data.media.id if spell.data.media.id
  17. # Localisation data
  18. locales.each do |locale|
  19. Mobility.with_locale(locale[0]) do
  20. wow_spell.name = spell.data.name[locale[1]]
  21. end
  22. end
  23. wow_spell.save
  24. end
  25. # Create a new job for the next batch if keep_going_on is true
  26. return unless keep_going_on && !result.results.count.zero?
  27. WowSpellsWorker.perform_async(result.results.last.data.id + 1, batch_size, keep_going_on)
  28. end
  29. end

app/workers/wow_standing_worker.rb

0.0% lines covered

20 relevant lines. 0 lines covered and 20 lines missed.
    
  1. # frozen_string_literal: true
  2. class WowStandingWorker < WowSidekiqWorker
  3. def perform(wow_character_id)
  4. return unless (wow_character = WowCharacter.find_by(character_id: wow_character_id))
  5. RBattlenet.set_options(locale: 'en_US')
  6. params = { realm: wow_character.wow_realm.slug, name: wow_character.name.downcase }
  7. result = RBattlenet::Wow::Character::Reputations.find(params)
  8. return unless result.status_code == 200
  9. result.reputations&.each do |reputation|
  10. next unless (wow_reputation = WowReputation.find_by(reputation_id: reputation.faction.id))
  11. wow_standing = WowStanding.where(wow_reputation: wow_reputation, wow_character: wow_character).first_or_initialize
  12. wow_standing.wow_reputation = wow_reputation
  13. wow_standing.wow_character = wow_character
  14. wow_standing.raw = reputation.standing.raw
  15. wow_standing.value = reputation.standing.value
  16. wow_standing.max = reputation.standing.max
  17. wow_standing.tier = reputation.standing.tier
  18. wow_standing.save
  19. end
  20. end
  21. end