Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We postgres now #762

Merged
merged 3 commits into from
May 19, 2024
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ gem 'simple_enum'
gem 'record_tag_helper'

# Database
gem 'mysql2'
gem 'pg'

group :development do
gem 'rails-erd'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ GEM
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mutex_m (0.2.0)
mysql2 (0.5.6)
net-http (0.4.1)
uri
net-imap (0.4.11)
Expand Down Expand Up @@ -251,6 +250,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
Expand Down Expand Up @@ -495,10 +495,10 @@ DEPENDENCIES
letter_opener
listen
minitest (= 5.15.0)
mysql2
omniauth-rails_csrf_protection
omniauth-zeuswpi
paper_trail
pg
poltergeist
puma
rails (~> 6.1)
Expand Down
2 changes: 1 addition & 1 deletion app/actions/user/fetch_enrolled_clubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(user)

def call
resp = HTTParty.get("http://registratie.fkgent.be/api/v2/members/clubs_for_ugent_nr.json", query:
{ key: Rails.application.secrets.enrollment_key, ugent_nr: user.cas_ugentStudentID })
{ key: Rails.application.secrets.enrollment_key, ugent_nr: user.cas_ugentstudentid })

return unless resp.code == 200

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,7 +22,7 @@ def show
return unless current_user

@registration.name = current_user.display_name
@registration.student_number = current_user.cas_ugentStudentID
@registration.student_number = current_user.cas_ugentstudentid
@registration.email = current_user.cas_mail

respond_to do |format|
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -49,7 +49,7 @@ def create
@registration.paid = 0

# overwrite student_number so setting this will not work
@registration.student_number = current_user.cas_ugentStudentID if requested_access_level.requires_login?
@registration.student_number = current_user.cas_ugentstudentid if requested_access_level.requires_login?

# Send the confirmation email.
if @registration.save
Expand Down
2 changes: 1 addition & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions app/models/access_level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ def price=(value)
#
# Table name: access_levels
#
# id :integer not null, primary key
# capacity :integer
# id :bigint not null, primary key
# capacity :bigint
# has_comment :boolean
# hidden :boolean
# name :string(255)
# permit :string(255) default("everyone")
# price :integer
# price :bigint
# created_at :datetime
# updated_at :datetime
# event_id :integer
# event_id :bigint
#
# Indexes
#
# index_access_levels_on_event_id (event_id)
# idx_16847_index_access_levels_on_event_id (event_id)
#
# Foreign Keys
#
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
4 changes: 2 additions & 2 deletions app/models/club.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def name
#
# Table name: clubs
#
# id :integer not null, primary key
# id :bigint not null, primary key
# display_name :string(255)
# full_name :string(255)
# internal_name :string(255)
Expand All @@ -31,5 +31,5 @@ def name
#
# Indexes
#
# index_clubs_on_internal_name (internal_name) UNIQUE
# idx_16882_index_clubs_on_internal_name (internal_name) UNIQUE
#
12 changes: 6 additions & 6 deletions app/models/clubs_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class ClubsUser < ApplicationRecord
#
# Table name: clubs_users
#
# club_id :integer
# user_id :integer
# club_id :bigint
# user_id :bigint
#
# Indexes
#
# fk_rails_b7c6964840 (user_id)
# index_clubs_users_on_club_id_and_user_id (club_id,user_id) UNIQUE
# idx_16891_fk_rails_b7c6964840 (user_id)
# idx_16891_index_clubs_users_on_club_id_and_user_id (club_id,user_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade
# fk_rails_... (user_id => users.id) ON DELETE => cascade
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade ON UPDATE => restrict
# fk_rails_... (user_id => users.id) ON DELETE => cascade ON UPDATE => restrict
#
14 changes: 7 additions & 7 deletions app/models/enrolled_clubs_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class EnrolledClubsMember < ApplicationRecord
#
# Table name: enrolled_clubs_members
#
# club_id :integer not null
# user_id :integer not null
# club_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_enrolled_clubs_members_on_club_id (club_id)
# index_enrolled_clubs_members_on_club_id_and_user_id (club_id,user_id) UNIQUE
# index_enrolled_clubs_members_on_user_id (user_id)
# idx_16894_index_enrolled_clubs_members_on_club_id (club_id)
# idx_16894_index_enrolled_clubs_members_on_club_id_and_user_id (club_id,user_id) UNIQUE
# idx_16894_index_enrolled_clubs_members_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade
# fk_rails_... (user_id => users.id) ON DELETE => cascade
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade ON UPDATE => restrict
# fk_rails_... (user_id => users.id) ON DELETE => cascade ON UPDATE => restrict
#
14 changes: 7 additions & 7 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def toggle_registration_open
#
# Table name: events
#
# id :integer not null, primary key
# id :bigint not null, primary key
# bank_number :string(255)
# contact_email :string(255)
# description :text(16777215)
# description :text
# end_date :datetime
# export_content_type :string(255)
# export_file_name :string(255)
# export_file_size :integer
# export_file_size :bigint
# export_status :string(255)
# export_updated_at :datetime
# location :string(255)
Expand All @@ -56,18 +56,18 @@ def toggle_registration_open
# require_physical_ticket :boolean default(FALSE), not null
# show_statistics :boolean
# show_ticket_count :boolean default(TRUE)
# signature :text(65535)
# signature :text
# start_date :datetime
# website :string(255)
# created_at :datetime
# updated_at :datetime
# club_id :integer
# club_id :bigint
#
# Indexes
#
# fk_rails_fc45ac705d (club_id)
# idx_16898_fk_rails_fc45ac705d (club_id)
#
# Foreign Keys
#
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade ON UPDATE => restrict
#
20 changes: 10 additions & 10 deletions app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def deliver
#
# Table name: partners
#
# id :integer not null, primary key
# id :bigint not null, primary key
# authentication_token :string(255)
# confirmed :boolean
# current_sign_in_at :datetime
Expand All @@ -44,21 +44,21 @@ def deliver
# remember_created_at :datetime
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# sign_in_count :integer default(0), not null
# sign_in_count :bigint default(0), not null
# created_at :datetime
# updated_at :datetime
# access_level_id :integer
# event_id :integer
# access_level_id :bigint
# event_id :bigint
#
# Indexes
#
# fk_rails_188986c214 (event_id)
# index_partners_on_access_level_id (access_level_id)
# index_partners_on_authentication_token (authentication_token)
# index_partners_on_reset_password_token (reset_password_token) UNIQUE
# idx_16916_fk_rails_188986c214 (event_id)
# idx_16916_index_partners_on_access_level_id (access_level_id)
# idx_16916_index_partners_on_authentication_token (authentication_token)
# idx_16916_index_partners_on_reset_password_token (reset_password_token) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (access_level_id => access_levels.id)
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (access_level_id => access_levels.id) ON DELETE => restrict ON UPDATE => restrict
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
26 changes: 12 additions & 14 deletions app/models/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class Registration < ApplicationRecord
end
end

default_scope { order "name ASC" }

def paid
from_cents read_attribute(:paid)
end
Expand Down Expand Up @@ -134,32 +132,32 @@ def to_cents(value)
#
# Table name: registrations
#
# id :integer not null, primary key
# id :bigint not null, primary key
# barcode :string(255)
# barcode_data :string(255)
# checked_in_at :datetime
# comment :text(65535)
# comment :text
# email :string(255)
# name :string(255)
# paid :integer
# paid :bigint
# payment_code :string(255)
# price :integer
# price :bigint
# student_number :string(255)
# token :string(255) not null
# created_at :datetime
# updated_at :datetime
# access_level_id :integer not null
# event_id :integer
# access_level_id :bigint not null
# event_id :bigint
#
# Indexes
#
# index_registrations_on_access_level_id (access_level_id)
# index_registrations_on_event_id (event_id)
# index_registrations_on_payment_code (payment_code) UNIQUE
# index_registrations_on_token (token)
# idx_16930_index_registrations_on_access_level_id (access_level_id)
# idx_16930_index_registrations_on_event_id (event_id)
# idx_16930_index_registrations_on_payment_code (payment_code) UNIQUE
# idx_16930_index_registrations_on_token (token)
#
# Foreign Keys
#
# fk_rails_... (access_level_id => access_levels.id)
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (access_level_id => access_levels.id) ON DELETE => restrict ON UPDATE => restrict
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class User < ApplicationRecord
after_create :enqueue_fetch_club, :enqueue_fetch_enrolled_clubs

# this should add all extra CAS attributes returned by the server to the current session
# extra var in session: cas_givenname, cas_surname, cas_ugentStudentID, cas_mail, cas_uid (= UGent login)
# extra var in session: cas_givenname, cas_surname, cas_ugentstudentid, cas_mail, cas_uid (= UGent login)
def cas_extra_attributes=(extra_attributes)
extra_attributes.each do |name, value|
# I prefer a case over reflection; this is safer if we suddenly get an
Expand All @@ -27,7 +27,7 @@ def cas_extra_attributes=(extra_attributes)
when :surname
self.cas_surname = value
when :ugentStudentID
self.cas_ugentStudentID = value
self.cas_ugentstudentid = value
when :mail
self.cas_mail = value
when :uid
Expand All @@ -37,7 +37,7 @@ def cas_extra_attributes=(extra_attributes)

self.save!

if self.cas_ugentStudentID # rubocop:disable Style/GuardClause
if self.cas_ugentstudentid # rubocop:disable Style/GuardClause
enqueue_fetch_club
enqueue_fetch_enrolled_clubs
end
Expand Down Expand Up @@ -79,24 +79,24 @@ def self.from_omniauth(auth)
#
# Table name: users
#
# id :integer not null, primary key
# id :bigint not null, primary key
# admin :boolean
# cas_givenname :string(255)
# cas_mail :string(255)
# cas_surname :string(255)
# cas_ugentStudentID :string(255)
# cas_ugentstudentid :string(255)
# cas_uid :string(255)
# current_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_at :datetime
# last_sign_in_ip :string(255)
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# sign_in_count :bigint default(0), not null
# username :string(255) not null
# created_at :datetime
# updated_at :datetime
#
# Indexes
#
# index_users_on_username (username) UNIQUE
# idx_16946_index_users_on_username (username) UNIQUE
#
Loading