Verify existing created sort option for workshops#1034
Conversation
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
|
@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. |
|
@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>
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. |
The "created" sort already works this way. It prioritizes year/month when present (lines 205-209 in workshop_search_service.rb), sorting by: |
| scope.total_entries | ||
| elsif scope.respond_to?(:count) | ||
| count = scope.count | ||
| count = scope.unscope(:select).count |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
don't show story population on workshops tags dropdowns
| # Compute the effective sort | ||
| def default_sort | ||
| params[:sort].presence || "created" | ||
| params[:sort].presence || "title" |
| @workshops = @workshops.order(title: :asc) | ||
| @workshops = @workshops.order( | ||
| Arel.sql("LOWER(TRIM(#{Workshop.strip_punctuation_sql_spaced('workshops.title')})) ASC") | ||
| ) |
There was a problem hiding this comment.
alphabetize on stripped and downcased title
| items: @windows_types, | ||
| label_method: :short_name, | ||
| param_name: :windows_types %> | ||
|
|
There was a problem hiding this comment.
move windows audience first bc people weren't noticing it
|
@copilot fix the broken tests and brakeman warning |
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/monthfields when present, then falls back tocreated_attimestamp.How did you approach the change?
Verification performed:
_sort_by_options.html.erbworkshop_search_service_spec.rbvalidates the sort behaviorSort behavior:
The "created" sort orders workshops using:
CASE WHEN year/month THEN 1 ELSE 2 END, year DESC, month DESC, created_at DESC, title ASCAnything 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.