Skip to content

Verify existing created sort option for workshops#1034

Open
Copilot wants to merge 8 commits intomainfrom
copilot/add-sort-by-most-recent
Open

Verify existing created sort option for workshops#1034
Copilot wants to merge 8 commits intomainfrom
copilot/add-sort-by-most-recent

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

What is the goal of this PR and why is this important?

Verifies that the existing "created" sort option for workshops is properly displayed in the UI and has adequate test coverage. The "created" sort (displayed as "Newest" in the UI) orders workshops by year/month fields when present, then falls back to created_at timestamp.

How did you approach the change?

Verification performed:

  • Confirmed the "created" sort is displayed in the UI as "Newest" in _sort_by_options.html.erb
  • Verified existing test coverage in workshop_search_service_spec.rb validates the sort behavior
  • Ran tests to ensure the sort functionality works correctly

Sort behavior:
The "created" sort orders workshops using: CASE WHEN year/month THEN 1 ELSE 2 END, year DESC, month DESC, created_at DESC, title ASC

Anything else to add?

Initial implementation added a new "most_recent" sort option, but this was reverted after feedback indicated the existing "created" sort already provides the needed functionality and just needed verification that it was working properly with adequate tests.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Copilot AI changed the title [WIP] Add sort by most recent to workshops Add most_recent sort option for workshops by created_at Feb 15, 2026
Copilot AI requested a review from maebeale February 15, 2026 17:33
@maebeale
Copy link
Collaborator

@copilot sorry, i didn't realize we already had a created search. i want to show that in the UI as a sort option. please make sure it works and there are adequate tests.

@maebeale
Copy link
Collaborator

@copilot the created search should search year/month first, if present, bc that's the displayed created at that's an override to created at.

Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot sorry, i didn't realize we already had a created search. i want to show that in the UI as a sort option. please make sure it works and there are adequate tests.

Reverted the "most_recent" addition in de2308e. The existing "created" sort is already shown in the UI as "Newest" and has passing tests. It sorts by year/month (when present) then created_at DESC.

Copilot AI changed the title Add most_recent sort option for workshops by created_at Verify existing created sort option for workshops Feb 15, 2026
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot the created search should search year/month first, if present, bc that's the displayed created at that's an override to created at.

The "created" sort already works this way. It prioritizes year/month when present (lines 205-209 in workshop_search_service.rb), sorting by: CASE WHEN year/month THEN 1 ELSE 2 END, year DESC, month DESC, created_at DESC, title ASC. The test verifies this behavior - workshops with year/month appear first, sorted newest to oldest.

@maebeale maebeale marked this pull request as ready for review February 15, 2026 20:09
scope.total_entries
elsif scope.respond_to?(:count)
count = scope.count
count = scope.unscope(:select).count
Copy link
Collaborator

Choose a reason for hiding this comment

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

an ahoy test was breaking bc of this

@category_types = CategoryType.published.order(:name).decorate
@sectors = Sector.published
@category_types = CategoryType.published.where(story_specific: false).order(:name).decorate
@sectors = Sector.published.order(:name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

alphabetize sector names in dropdowns

authorize!
@category_types = CategoryType.published.order(:name).decorate
@sectors = Sector.published
@category_types = CategoryType.published.where(story_specific: false).order(:name).decorate
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't show story population on workshops tags dropdowns

# Compute the effective sort
def default_sort
params[:sort].presence || "created"
params[:sort].presence || "title"
Copy link
Collaborator

Choose a reason for hiding this comment

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

change default sort

@workshops = @workshops.order(title: :asc)
@workshops = @workshops.order(
Arel.sql("LOWER(TRIM(#{Workshop.strip_punctuation_sql_spaced('workshops.title')})) ASC")
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

alphabetize on stripped and downcased title

items: @windows_types,
label_method: :short_name,
param_name: :windows_types %>

Copy link
Collaborator

Choose a reason for hiding this comment

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

move windows audience first bc people weren't noticing it

@maebeale
Copy link
Collaborator

@copilot fix the broken tests and brakeman warning

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