File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,11 @@ def initialize_guest_data
3636 def load_recommendations
3737 # Check if recommendations exist and are fresh
3838 if Recommendation . fresh_for_user? ( current_user )
39- # Load cached recommendations
40- @recommended_animes = current_user . recommended_animes
41- . joins ( :recommendations )
42- . where ( recommendations : { user_id : current_user . id } )
43- . merge ( Recommendation . top ( 12 ) ) # Show top 12
44- . to_a
39+ # Load top 12 recommendations with anime preloaded
40+ recommendations = current_user . recommendations
41+ . includes ( :anime )
42+ . top ( 12 )
43+ @recommended_animes = recommendations . map ( &:anime )
4544 else
4645 # Recommendations stale or don't exist - show cold start
4746 @recommended_animes = load_cold_start_recommendations
Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ def fetch_candidate_anime
4848 collab_candidates = fetch_collaborative_candidates
4949 popular_candidates = fetch_popular_candidates
5050
51- # combine and deduplicate
51+ # combine and deduplicate by anime ID
5252 ( genre_candidates + collab_candidates + popular_candidates )
53- . uniq
53+ . uniq ( & :id )
5454 # filter out anime alr in the user's anime list
5555 . reject { |anime | @user_anime_ids . include? ( anime . id ) }
5656 # grab first CANDIDATE_LIMIT items
You can’t perform that action at this time.
0 commit comments