From ba9d19c832d1bc5bab2e2d4ff3ec7a3e7a47a5a2 Mon Sep 17 00:00:00 2001 From: sspsk Date: Sat, 16 Dec 2017 15:39:43 +0200 Subject: [PATCH 1/2] change uniq to distinct for SQL queries to fix deprecation --- app/controllers/admin/questions_controller.rb | 2 +- app/controllers/admin/versions_controller.rb | 2 +- app/controllers/admin/volunteers_controller.rb | 2 +- app/controllers/api/v1/speakers_controller.rb | 2 +- app/controllers/booths_controller.rb | 2 +- app/helpers/users_helper.rb | 2 +- app/models/admin_ability.rb | 2 +- app/models/program.rb | 2 +- app/views/schedules/show.xml.haml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index 71abc7a1..99433eb5 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -11,7 +11,7 @@ module Admin end def show - @registrations = @conference.registrations.joins(:qanswers).uniq + @registrations = @conference.registrations.joins(:qanswers).distinct end def new diff --git a/app/controllers/admin/versions_controller.rb b/app/controllers/admin/versions_controller.rb index 5056f3ff..24c781b9 100644 --- a/app/controllers/admin/versions_controller.rb +++ b/app/controllers/admin/versions_controller.rb @@ -9,7 +9,7 @@ module Admin if current_user.has_role? :organization_admin, :any @conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten end - @conferences_with_role.uniq! + @conferences_with_role.distinct! return if @conference.blank? @versions = PaperTrail::Version.where(conference_id: @conference.id).accessible_by(current_ability) diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index aefa682a..eef0c348 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -14,7 +14,7 @@ module Admin def show if can_manage_volunteers?(@conference) @volunteers = if @conference.use_vpositions - @conference.registrations.joins(:vchoices).uniq + @conference.registrations.joins(:vchoices).distinct else @conference.registrations.where(volunteer: true) end diff --git a/app/controllers/api/v1/speakers_controller.rb b/app/controllers/api/v1/speakers_controller.rb index 2706d2e9..7912f36f 100644 --- a/app/controllers/api/v1/speakers_controller.rb +++ b/app/controllers/api/v1/speakers_controller.rb @@ -15,7 +15,7 @@ module Api users = User.joins(:event_users) end - users = users.where(event_users: {event_role: :speaker}).uniq + users = users.where(event_users: {event_role: :speaker}).distinct render json: users, each_serializer: SpeakerSerializer, callback: params['callback'] end end diff --git a/app/controllers/booths_controller.rb b/app/controllers/booths_controller.rb index f0457b88..fa919cee 100644 --- a/app/controllers/booths_controller.rb +++ b/app/controllers/booths_controller.rb @@ -5,7 +5,7 @@ class BoothsController < ApplicationController skip_authorize_resource only: [:withdraw, :confirm, :restart] def index - @booths = current_user.booths.where(conference_id: @conference.id).uniq + @booths = current_user.booths.where(conference_id: @conference.id).distinct end def show; end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 763a44c9..b77ac731 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -18,7 +18,7 @@ module UsersHelper providers << provider if !ENV["OSEM_#{provider.upcase}_KEY"].blank? && !ENV["OSEM_#{provider.upcase}_SECRET"].blank? end - providers.uniq + providers.distinct end # Receives a hash, generated from User model, function get_roles diff --git a/app/models/admin_ability.rb b/app/models/admin_ability.rb index cc318da2..6b5269f2 100644 --- a/app/models/admin_ability.rb +++ b/app/models/admin_ability.rb @@ -103,7 +103,7 @@ class AdminAbility def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = []) # ids of all the conferences for which the user has the 'organizer' role and # conferences that belong to organizations for which user is 'organization_admin' - conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq + conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).distinct # ids of all the tracks that belong to the programs of the above conferences track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id) diff --git a/app/models/program.rb b/app/models/program.rb index 4f0298f4..8a910017 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -227,7 +227,7 @@ class Program < ApplicationRecord languages.match(/^$|(\A[a-z][a-z](,[a-z][a-z])*\z)/).present? languages_array = languages.split(',') # We check that languages are not repeated - errors.add(:languages, "can't be repeated") && return unless languages_array.uniq!.nil? + errors.add(:languages, "can't be repeated") && return unless languages_array.distinct!.nil? # We check if every language is a valid ISO 639-1 language errors.add(:languages, 'must be ISO 639-1 valid codes') unless languages_array.select{ |x| ISO_639.find(x).nil? }.empty? end diff --git a/app/views/schedules/show.xml.haml b/app/views/schedules/show.xml.haml index 541377ad..c0dbb17c 100644 --- a/app/views/schedules/show.xml.haml +++ b/app/views/schedules/show.xml.haml @@ -32,5 +32,5 @@ %license/ %optout=false #FIXME %persons - - event.speakers.uniq.each do |speaker| + - event.speakers.distinct.each do |speaker| %person{ id: speaker.id }= speaker.name From ff166689417549288d277dd35f51758e68b33bc2 Mon Sep 17 00:00:00 2001 From: sspsk Date: Sat, 16 Dec 2017 17:11:43 +0200 Subject: [PATCH 2/2] fix travis error --- app/models/admin_ability.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/admin_ability.rb b/app/models/admin_ability.rb index 6b5269f2..cc318da2 100644 --- a/app/models/admin_ability.rb +++ b/app/models/admin_ability.rb @@ -103,7 +103,7 @@ class AdminAbility def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = []) # ids of all the conferences for which the user has the 'organizer' role and # conferences that belong to organizations for which user is 'organization_admin' - conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).distinct + conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq # ids of all the tracks that belong to the programs of the above conferences track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id)