Skip to content

feat(featured_trainer): choose how many trainers to feature#1340

Open
kennethrioja wants to merge 1 commit into
ElixirTeSS:masterfrom
kennethrioja:n-trainers
Open

feat(featured_trainer): choose how many trainers to feature#1340
kennethrioja wants to merge 1 commit into
ElixirTeSS:masterfrom
kennethrioja:n-trainers

Conversation

@kennethrioja

Copy link
Copy Markdown
Contributor

Summary of changes

  • We can now choose how many trainers we want to feature in the home page

Motivation and context

The value 1 was hardcoded, I wanted more

Screenshots

N/A

Checklist

  • I have read and followed the CONTRIBUTING guide.
  • I confirm that I have the authority necessary to make this contribution on behalf of its copyright owner and agree to license it to the TeSS codebase under the BSD license.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurability for the “Featured trainer” section on the home page by interpreting the site.home_page.featured_trainer setting as a trainer count rather than a boolean toggle.

Changes:

  • Update StaticController#set_featured_trainer to sample a configurable number of trainers.
  • Update home page controller test expectations to reflect multiple featured trainers and add a “disabled” case.
  • Update example config to document the new meaning of featured_trainer (count; blank disables).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
app/controllers/static_controller.rb Uses the configured featured_trainer value as the sample size when selecting featured trainers.
test/controllers/static_controller_test.rb Adjusts assertions for multiple featured trainers and adds a “not shown when nil” case.
config/tess.example.yml Documents featured_trainer as a numeric count with blank meaning disabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 39 to +41
f_trainers = trainers.where.not(users: { image_file_size: nil })
trainers = f_trainers.exists? ? f_trainers : trainers
trainers.sample(1)
trainers.sample(TeSS::Config.site.dig('home_page', 'featured_trainer'))
Comment on lines 314 to +320
test 'should show featured trainer' do
with_settings({ site: { home_page: { featured_trainer: true } } }) do
with_settings({ site: { home_page: { featured_trainer: 2 } } }) do
get :home
assert_select 'section#featured_trainer', count: 1
assert_select 'section#featured_trainer h2', count: 1
assert_select 'section#featured_trainer li', count: 1
assert_select 'section#featured_trainer li', count: 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants