From 796d0e0f4e3711229b245e3858089df8070522a8 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Sun, 19 May 2024 14:06:19 +0200 Subject: [PATCH] Passing pipeline --- app/controllers/events_controller.rb | 6 +++--- app/controllers/registrations_controller.rb | 2 +- app/models/ability.rb | 2 +- app/models/registration.rb | 2 -- docker-compose.yml | 1 - 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 0d6a0cab..07c086cf 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -8,9 +8,9 @@ class EventsController < ApplicationController respond_to :html, :js, :ics def index - @events = Event.where('end_date > ?', DateTime.now).order(:start_date) + @events = Event.where('end_date > ?', DateTime.now).order(start_date: :asc) @past_events = if user_signed_in? - Event.accessible_by(current_ability).order(:name) + Event.accessible_by(current_ability).order(start_date: :desc) else [] end @@ -84,7 +84,7 @@ def statistics @data = @event.access_levels.map do |al| { name: al.name, - data: zeros.merge(al.registrations.group('registrations.name, date(registrations.created_at)').count.transform_keys { |key| key.strftime("%Y-%m-%d") }) + data: zeros.merge(al.registrations.group('date(registrations.created_at)').count.transform_keys { |key| key.strftime("%Y-%m-%d") }) } end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 74e9d6d7..9ac091dc 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -12,7 +12,7 @@ def index authorize! :read, @event - @registrationsgrid = RegistrationsGrid.new(params[:registrations_grid]) do |scope| + @registrationsgrid = RegistrationsGrid.new(order: :name, **params.fetch(:registrations_grid, {}).permit!) do |scope| scope.where(event_id: @event.id).order(Arel.sql("registrations.price - paid DESC")) end diff --git a/app/models/ability.rb b/app/models/ability.rb index eadff5b7..47acff51 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -32,7 +32,7 @@ def user_rules(user) if clubs.present? can :create, Event can :show, Event - can :crud, Event, ["? IN (?)", :club_id, clubs.pluck(:id)] do |e| + can :crud, Event, ["club_id IN (?)", clubs.ids] do |e| clubs.include? e.club end else diff --git a/app/models/registration.rb b/app/models/registration.rb index 3dfbcdee..84c3296f 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -35,8 +35,6 @@ class Registration < ApplicationRecord end end - default_scope { order "name ASC" } - def paid from_cents read_attribute(:paid) end diff --git a/docker-compose.yml b/docker-compose.yml index 00859585..0e82e694 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,7 +31,6 @@ services: - "6379:6379" volumes: - db_data: gandalf_data: gandalf_test_data: redis_data: