diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e071fad..8ba54849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Modified - user navigation +- icons for fantasy teams in navigation ## [1.2.1] - 2024-02-29 ### Added diff --git a/app/assets/images/leagues/no_text_bundesliga.webp b/app/assets/images/leagues/no_text_bundesliga.webp new file mode 100644 index 00000000..56fcaf99 Binary files /dev/null and b/app/assets/images/leagues/no_text_bundesliga.webp differ diff --git a/app/assets/images/leagues/no_text_champions_league.webp b/app/assets/images/leagues/no_text_champions_league.webp new file mode 100644 index 00000000..12f353c4 Binary files /dev/null and b/app/assets/images/leagues/no_text_champions_league.webp differ diff --git a/app/assets/images/leagues/no_text_epl.webp b/app/assets/images/leagues/no_text_epl.webp new file mode 100644 index 00000000..c3575351 Binary files /dev/null and b/app/assets/images/leagues/no_text_epl.webp differ diff --git a/app/assets/images/leagues/no_text_la_liga.webp b/app/assets/images/leagues/no_text_la_liga.webp new file mode 100644 index 00000000..5e89b9ab Binary files /dev/null and b/app/assets/images/leagues/no_text_la_liga.webp differ diff --git a/app/assets/images/leagues/no_text_nba.webp b/app/assets/images/leagues/no_text_nba.webp new file mode 100644 index 00000000..c5bb6c32 Binary files /dev/null and b/app/assets/images/leagues/no_text_nba.webp differ diff --git a/app/assets/images/leagues/no_text_rpl.webp b/app/assets/images/leagues/no_text_rpl.webp new file mode 100644 index 00000000..c4e0d9c0 Binary files /dev/null and b/app/assets/images/leagues/no_text_rpl.webp differ diff --git a/app/assets/images/leagues/no_text_seria_a.webp b/app/assets/images/leagues/no_text_seria_a.webp new file mode 100644 index 00000000..a18b9696 Binary files /dev/null and b/app/assets/images/leagues/no_text_seria_a.webp differ diff --git a/app/controllers/oracul_places_controller.rb b/app/controllers/oracul_places_controller.rb index 5007354d..817d40e1 100644 --- a/app/controllers/oracul_places_controller.rb +++ b/app/controllers/oracul_places_controller.rb @@ -11,7 +11,10 @@ def show; end private def find_leagues - @leagues = League.hashable_pluck(:id, :background_url, :sport_kind) + @leagues = + Rails.cache.fetch('oracul_places_show_leagues_v1', expires_in: 24.hours, race_condition_ttl: 10.seconds) do + League.hashable_pluck(:id, :background_url, :sport_kind) + end end def find_oracul_places diff --git a/app/views/components/page_wrappers/page_component.html.erb b/app/views/components/page_wrappers/page_component.html.erb index 5996b8db..4922e1b6 100644 --- a/app/views/components/page_wrappers/page_component.html.erb +++ b/app/views/components/page_wrappers/page_component.html.erb @@ -75,7 +75,7 @@ <% global_user_fantasy_teams.each do |user_fantasy_team| %>
<%= link_to fantasy_team_points_path(user_fantasy_team[:uuid]), class: 'flex items-center px-4 py-2' do %> - <%= image_tag "icons/#{user_fantasy_team[:leagues_sport_kind]}.svg", class: 'w-8 h-8 mr-2' %> + <%= image_tag background_urls.dig('Season', user_fantasy_team[:season_id]).split('/').join('/no_text_'), class: 'w-8 h-8 mr-2 bg-white rounded-full' %> <%= user_fantasy_team[:name] %> <% end %> <% if user_fantasy_team[:uuid] == @fantasy_team&.uuid %> @@ -99,6 +99,7 @@ <% global_user_oraculs.each do |global_user_oracul| %>
<%= link_to oracul_path(global_user_oracul[:uuid]), class: 'flex items-center px-4 py-2' do %> + <%= image_tag background_urls.dig(global_user_oracul[:placeable_type], global_user_oracul[:placeable_id]).split('/').join('/no_text_'), class: 'w-8 h-8 mr-2 bg-white rounded-full' %> <%= global_user_oracul[:name] %> <% end %>
diff --git a/app/views/components/page_wrappers/page_component.rb b/app/views/components/page_wrappers/page_component.rb index e4f19ee7..740ba934 100644 --- a/app/views/components/page_wrappers/page_component.rb +++ b/app/views/components/page_wrappers/page_component.rb @@ -13,9 +13,9 @@ def initialize(fantasy_team: nil, oracul: nil) def global_user_fantasy_teams @global_user_fantasy_teams ||= Current.user - .fantasy_teams.completed - .joins(season: :league) - .hashable_pluck(:uuid, :name, 'leagues.sport_kind') + .fantasy_teams + .completed + .hashable_pluck(:uuid, :name, :season_id) end def global_user_oraculs @@ -24,7 +24,17 @@ def global_user_oraculs .oraculs .joins(:oracul_place) .where(oracul_places: { active: true }) - .hashable_pluck(:uuid, :name) + .hashable_pluck(:uuid, :name, :placeable_id, :placeable_type) + end + + private + + def background_urls + @background_urls ||= + { + 'Season' => Season.joins(:league).pluck(:id, 'leagues.background_url').to_h.symbolize_keys, + 'Cup' => Cup.joins(:league).pluck(:id, 'leagues.background_url').to_h.symbolize_keys + } end end end