Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .claude/commands/fix-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Before writing any code:

- Stage all changes with `git add`
- Write a concise, descriptive commit message referencing the issue (e.g. `Fix login bug (#1234)`)
- The commit message must end with a co-author line:
```
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
```
- Commit the changes

## Step 7: Open a PR
Expand All @@ -56,6 +60,7 @@ Before writing any code:
2. Create a PR with `gh pr create`:
- Title should summarize the fix
- Body should reference the issue (`Fixes #<issue-number>`) and briefly describe what changed
- Body must end with: `🤖 Generated with [Claude Code](https://claude.com/claude-code)`
3. Add labels using the GitHub REST API (required — gh pr edit is broken):

```
Expand Down
28 changes: 16 additions & 12 deletions app/controllers/csv_exports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# frozen_string_literal: true
class CsvExportsController < ApplicationController
class RunSignupsFilenameFinder
PRIORITIZED_FILENAME_GENERATORS = [
->(run) { run.event.title },
->(run) { "#{run.event.title} (#{run.title_suffix})" },
->(run) { "#{run.event.title} (#{format_run_start_day(run)})" },
->(run) { "#{run.event.title} (#{format_run_start_time(run)})" },
->(run) { "#{run.event.title} (#{format_run_rooms(run)})" },
->(run) { "#{run.event.title} (#{format_run_start_day(run)} in #{format_run_rooms(run)})" },
->(run) { "#{run.event.title} (#{format_run_start_time(run)} in #{format_run_rooms(run)})" },
->(run) { "#{run.event.title} (run #{run.id})" }
].freeze

def format_run_start_day(run)
run.starts_at.strftime("%a")
end
Expand All @@ -28,13 +17,28 @@ def format_run_rooms(run)
# strategies
def unique_filename(event, run, suffix)
filename_generator =
PRIORITIZED_FILENAME_GENERATORS.find do |generator|
filename_generators.find do |generator|
filenames = event.runs.map { |r| generator.call(r) }
filenames.uniq.size == filenames.size
end

"#{filename_generator.call(run)} #{suffix}"
end

private

def filename_generators # rubocop:disable Metrics/AbcSize
[
->(r) { r.event.title },
->(r) { "#{r.event.title} (#{r.title_suffix})" },
->(r) { "#{r.event.title} (#{format_run_start_day(r)})" },
->(r) { "#{r.event.title} (#{format_run_start_time(r)})" },
->(r) { "#{r.event.title} (#{format_run_rooms(r)})" },
->(r) { "#{r.event.title} (#{format_run_start_day(r)} in #{format_run_rooms(r)})" },
->(r) { "#{r.event.title} (#{format_run_start_time(r)} in #{format_run_rooms(r)})" },
->(r) { "#{r.event.title} (run #{r.id})" }
]
end
end

include SendCsv
Expand Down
26 changes: 26 additions & 0 deletions test/controllers/csv_exports_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require "test_helper"

describe CsvExportsController::RunSignupsFilenameFinder do
let(:finder) { CsvExportsController::RunSignupsFilenameFinder.new }
let(:convention) { create(:convention) }
let(:event) { create(:event, convention: convention) }

describe "#unique_filename" do
it "disambiguates runs by start day when they share a title" do
run1 = create(:run, event: event, starts_at: convention.starts_at)
create(:run, event: event, starts_at: convention.starts_at + 1.day)

assert_equal(
"#{event.title} (#{run1.starts_at.strftime("%a")}) Signups",
finder.unique_filename(event, run1, "Signups")
)
end

it "uses just the event title when the event has only one run" do
run = create(:run, event: event, starts_at: convention.starts_at)

assert_equal "#{event.title} Signups", finder.unique_filename(event, run, "Signups")
end
end
end
Loading