Skip to content

Commit

Permalink
Merge pull request #962 from DaanVanVugt/feature/featured_trainer_onl…
Browse files Browse the repository at this point in the history
…y_with_image

only feature trainers with image
  • Loading branch information
fbacall authored Aug 29, 2024
2 parents 227e02b + 61ce586 commit 48402f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/static_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def set_featured_trainer
return nil unless TeSS::Config.site.dig('home_page', 'featured_trainer')

srand(Date.today.beginning_of_day.to_i)
Trainer.order(:id).sample(1)
trainers = Trainer.joins(:user).order(:id)
f_trainers = trainers.where.not(users: { image_file_size: nil })
trainers = f_trainers.exists? ? f_trainers : trainers
trainers.sample(1)
end

def set_content_providers
Expand Down

0 comments on commit 48402f3

Please sign in to comment.