Skip to content

Events stored in the database instead of YAML files - first draft - #487

Open
kcomandich wants to merge 13 commits into
rubyaustralia:mainfrom
kcomandich:feature/events_architecture
Open

Events stored in the database instead of YAML files - first draft#487
kcomandich wants to merge 13 commits into
rubyaustralia:mainfrom
kcomandich:feature/events_architecture

Conversation

@kcomandich

@kcomandich kcomandich commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Move events from a YAML file to the database, and provide a way to create/edit/delete events

There are a few remaining items to finish before it's ready to use, but I wanted to make sure I'm on the right track.

See discussion on #342. Implementation so far:

  • 1. Create an ApplicationRecord class DatabaseEvent (but use the events db table)
  • 2. Update the User class to add :meetup_admin scope
  • 3. Data migration & import from yaml file
  • 4. Clone the relevant views, except they’re populated from events table instead of yaml
  • 5. Add "Edit" button to meetup Event page to a form for updating the Event (ex. https://melbourne.ruby.org.au/events/2026-05-28-ruby-melbourne)
  • 6. Add "Add Event" button to meetup Events page (ex. https://melbourne.ruby.org.au/events) to a form for adding a new Event
  • 7. Create new events in the events table using the CRUD
  • 8. Check if it's all working - compare old views with new views (but see below for new changes)
  • 9. Replace the old views with the new views
  • 10. Delete old Event class
  • 11. Rename DatabaseEvent to Event

Note that UUIDs from the events.yml file don't appear to be used, LMK if they should be.

Still to do/fix:

  • Need ability to add/edit/delete Talks in the UI
  • Incorporate recent code changes - tabs for past/upcoming events, etc
  • In the Melbourne views, filter by region and event_type
  • fix: HTML is showing up in the description when saving it
  • Remove the date field and create a date method that just uses start_time (no need to have duplicate date and start_time fields)
  • Need ability to add/edit Venues in the UI

Thanks to @mcgain for advising! 🙏 🎉

Screenshots:

Clone of the Melbourne event/show page, using events table, with Edit and Delete buttons:

DatabaseEvent page with Edit and Delete Events

New/Edit Event form:

DatabaseEvent Edit form

Clone of the Melbourne events page, using events table, with New button:

DatabaseEvent list with New Event button

Clone of the Melbourne home page, using events table:

DatabaseEvents home

Comment thread db/migrate/20260707045525_create_events_and_import_from_yaml.rb Outdated
Comment thread db/migrate/20260707045525_create_events_and_import_from_yaml.rb Outdated
@@ -1,3 +1,4 @@
@use "@37signals/lexxy/dist/stylesheets/lexxy.css";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copied this from the main site because we now need the lexxy styles for editing the description field in the Melbourne site, and the styles are not shared.

Comment thread db/migrate/20260707045525_create_events_and_import_from_yaml.rb Outdated
Comment thread sites/melbourne/app/controllers/database_events_controller.rb Outdated
Comment thread sites/melbourne/app/presenters/event_presenter.rb Outdated
@kcomandich
kcomandich force-pushed the feature/events_architecture branch 4 times, most recently from c8b6c90 to 0b8ef91 Compare July 8, 2026 02:52

@mcgain mcgain 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.

Bunch of nit-picking sorry, but they are worth addressing

end

def self.upcoming(amount = nil)
all.select(&:today_or_in_the_future?).slice(0..amount&.-(1))

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.

I think because we're using all here and not all_by_date that the returned event might not actually be the next one. I think all will just return in database insertion order, then today_or_in_the_future? will ensure it's upcoming, but not necessarily the next one by date.

In reality, it is likely that events will be added in the correct order, but if a newer event were to be added, then we'd end up displaying the wrong one.

I suspect this used to be fine, because the yaml events would be ordered by date, but that's not necessarily true of the db.

This is also true of past

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.

This isn't super important to fix in this PR. It'll be fine in the short term, can be fixed in a followup IMO

all.reject(&:today_or_in_the_future?).reverse.slice(0..amount&.-(1))
end

def self.last(amount = 1)

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.

This overrides the ActiveRecord method last, which when given no argument, returns only a single object, rather than an array. Here, we're always returning an array and so break user expectations of the api.

Also, this is probably susceptible to the same issue as upcoming, so an all_by_date is probably necessary here and might allow you to avoid the reverse.

Comment thread sites/melbourne/app/controllers/database_events_controller.rb Outdated
Comment thread db/migrate/20260707045525_create_events_and_import_from_yaml.rb Outdated
Comment thread db/migrate/20260707045525_create_events_and_import_from_yaml.rb Outdated
Comment thread sites/melbourne/app/controllers/database_events_controller.rb Outdated

@mcgain mcgain 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.

one more

Comment thread db/migrate/20260707045525_create_events_and_import_from_yaml.rb Outdated
@kcomandich
kcomandich force-pushed the feature/events_architecture branch 4 times, most recently from 9c68ff4 to 1e2f75e Compare July 21, 2026 02:00
@kcomandich
kcomandich force-pushed the feature/events_architecture branch from 1e2f75e to 2360201 Compare July 21, 2026 02:42
@kcomandich
kcomandich marked this pull request as ready for review July 21, 2026 03:11
@kcomandich
kcomandich requested a review from a team as a code owner July 21, 2026 03:11
@leesheppard
leesheppard requested a review from HashNotAdam July 25, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants