Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Extract the events list UNION query out of EventsController

Aberta
#2,937 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
66/100
Tipo de issue
Refatoração
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
rails, ruby
Domínio
backend, database

Direção de pesquisa

Read EventsController and compare the existing app/queries/DashboardQuery and app/queries/SponsorsSearch patterns. Start with spec/controllers/events_controller_spec.rb and the feature specs touching the events pages; done means the controller has no Arel, behavior remains unchanged, and the specified specs pass.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

refactoring tech debt

Problem

EventsController builds the paginated upcoming/past events listing inside the controller: paginated_events (~80 lines) constructs a raw Arel UNION ALL across workshops, meetings, and events, plus a separate COUNT query and manual Pagy wiring, and load_events re-hydrates AR objects from the returned id/type pairs. fetch_upcoming_events and fetch_past_events are also near-duplicates of each other.

This is query logic, not HTTP coordination, and it makes the controller the largest non-admin one in the app. The repo already has app/queries/ (DashboardQuery, SponsorsSearch) — this work belongs there.

Proposed change

  • Move the UNION ALL construction, count, pagination, and re-hydration into a single query class, e.g. app/queries/events_feed_query.rb, with an upcoming: flag so fetch_upcoming_events / fetch_past_events collapse into one method.
  • Controller keeps only: parse params[:page], call the query, assign for the view.

Acceptance

  • EventsController#upcoming / #past are a few lines each and contain no Arel.
  • Existing behaviour unchanged: same ordering, grouping by date, 20 rows/page, DB-level count and pagination.
  • bundle exec rspec spec/controllers/events_controller_spec.rb (and the feature specs touching the events pages) pass.
Linguagem predominante
Ruby
Estrelas
105
Forks
206
Merge médio
19h 31min
PRs com merge (30d)
84

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de codebar/planner

Todas as issues de codebar/planner

Issues semelhantes

Mais issues de Ruby

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.