Skip to content

Coc as a timestamp#429

Open
tperdue321 wants to merge 6 commits into
minnestar:mainfrom
tperdue321:coc-as-a-timestamp
Open

Coc as a timestamp#429
tperdue321 wants to merge 6 commits into
minnestar:mainfrom
tperdue321:coc-as-a-timestamp

Conversation

@tperdue321
Copy link
Copy Markdown

Top level TL;DR

Replace CodeOfConductAgreement records with a coc_agreed_at timestamp

Simplifies code of conduct tracking by storing agreement as a single timestamp on participants rather than a separate join table record
per event.

Modifications

  • Add coc_agreed_at datetime column to participants
  • signed_code_of_conduct_for_current_event? now checks coc_agreed_at presence instead of querying code_of_conduct_agreements
  • ParticipantsController converts the code_of_conduct_agreement checkbox param to a coc_agreed_at timestamp before saving
  • SessionsController sets coc_agreed_at on the participant instead of creating a CodeOfConductAgreement record
  • Backfill rake task (backfill:coc_agreed_at) populates coc_agreed_at from existing code_of_conduct_agreements records
  • Updated tests and faker seed data to use the new field

@experimatt experimatt self-requested a review May 22, 2026 15:33

def coc_agreement_param_as_timestamp
if params[:participant][:code_of_conduct_agreement] == '1'
params[:participant] ||= {}
Copy link
Copy Markdown
Contributor

@experimatt experimatt May 22, 2026

Choose a reason for hiding this comment

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

Is this line meant to delete the :code_of_conduct_agreement key from params? If so, can you make that more explicit?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

it's not meant to as that's already handled in the strong params. This is more of a "derp" moment. It's checking if params[:participant] and setting it to an empty hash if not already present. Which is obviously ridiculous since we are checking a key on that hash 🤦 . I'll just delete the params[:participant] ||= {} line

Comment thread app/models/participant.rb Outdated
@tperdue321 tperdue321 requested a review from experimatt May 22, 2026 16:01
Copy link
Copy Markdown
Contributor

@experimatt experimatt left a comment

Choose a reason for hiding this comment

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

Tested locally and it works as expected - nice!

The two changes I'd like to see before approving & merging are:

  1. Change the backfill from a rake task to a migration
  2. Rename the helper signed_code_of_conduct_for_current_event? method

Comment thread lib/tasks/backfill.rake
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.

Suggestion: This should be a db migration, not a rake task. We should avoid writing raw SQL wherever possible, and use active record instead (as long as it's reasonably performant).

See this migration as an example (not the same, but similar idea): https://github.com/minnestar/sessionizer/blob/main/db/migrate/20260319035803_backfill_event_categories.rb

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.

Testing this locally made me realize that there are four places on the front-end where we currently show the CoC checkbox:

  • 2 in participant views (new and edit)
  • 2 in session views (new and edit, via the form partial)

With this change, we should be sure to update the front-end views accordingly to make sure we're capturing CoC agreements correctly and in the right places.


After running through all four scenarios locally, I think they're still working as expected. I don't think showing a checked checkbox that's also disabled, along with a link to the CoC, whenever a user is creating or editing a session, or editing their own profile hurts anything. It's a nice reminder that we have a CoC and expect attendees & presenters to follow it.

And it's also still worth including the checkbox in all 4 places because we already have existing users in the system who haven't necessarily accepted the CoC yet.

Sorry this is a bit of a word salad, but the TLDR is that the way we're currently presenting CoC checkboxes in the front-end seems like it'll still work with these changes. But I had to walk through each scenario locally and say it all out loud before it made sense to me 🙃

Comment thread app/models/participant.rb
@@ -82,12 +82,7 @@ def deliver_password_reset_instructions!
end

def signed_code_of_conduct_for_current_event?
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.

Suggestion: I think we should go ahead and rename this method to make it more clear, and update all the spots where we call it.

I think signed_code_of_conduct? is clear enough, but I'll defer to you on whatever you think makes the most sense.

Comment on lines +81 to +82
if session_params[:code_of_conduct_agreement] == '1' && !@session.participant.signed_code_of_conduct_for_current_event?
current_participant.update!(coc_agreed_at: Time.current)
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.

Suggestion: For consistency, these should both check current_participant (not @session.participant).

verify_owner already confirms that these two are the same, but we should be consistent anyway.

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