diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 0579097790de7c0b49400ad9676537504614a638..6edf2387280c0305d5a85cd77af40cb30647e494 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -4,7 +4,7 @@ class CollectionsController < ApplicationController # GET /collections # GET /collections.json def index - @collections = collection_repository.find_all + @collections = collection_repository.all end # GET /collections/1 @@ -56,7 +56,7 @@ class CollectionsController < ApplicationController private def set_collection - @collection = collection_repository.find_by_id params[:id] + @collection = collection_repository.find params[:id] end def collection_repository diff --git a/app/controllers/institutions_controller.rb b/app/controllers/institutions_controller.rb index 0eb2ca291f822c645e854198ba8bfc22330a4d07..96c21aa17d468af0acb632a45c2cbc9eb9de3bfc 100644 --- a/app/controllers/institutions_controller.rb +++ b/app/controllers/institutions_controller.rb @@ -4,7 +4,7 @@ class InstitutionsController < ApplicationController # GET /institutions # GET /institutions.json def index - @institutions = institution_repository.find_all + @institutions = institution_repository.all end # GET /institutions/1 @@ -62,7 +62,7 @@ class InstitutionsController < ApplicationController private def set_institution - @institution = institution_repository.find_by_id("##{params[:id]}") + @institution = institution_repository.find("##{params[:id]}") end def institution_repository diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index c61bdb7186eec207c7a93fa77e28c051bf627df5..3ded253c23cd10465b3624db636413ac3bf7b848 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -6,7 +6,7 @@ class LearningObjectsController < ApplicationController # GET /learning_objects # GET /learning_objects.json def index - @learning_objects = learning_object_repository.find_all + @learning_objects = learning_object_repository.all end # GET /learning_objects/1 @@ -73,7 +73,7 @@ class LearningObjectsController < ApplicationController # Use callbacks to share common setup or constraints between actions. def set_learning_object - @learning_object = learning_object_repository.find_by_id params[:id] + @learning_object = learning_object_repository.find params[:id] end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/management/highlights_controller.rb b/app/controllers/management/highlights_controller.rb index 2c91db6b179c71322b42d85ffff779913da35d78..fcfbba8b2aa52afc6ffd227e386ff9b52cc2ecee 100644 --- a/app/controllers/management/highlights_controller.rb +++ b/app/controllers/management/highlights_controller.rb @@ -1,7 +1,7 @@ class Management::HighlightsController < ManagementController def index - @highlights = highlight_repository.find_all + @highlights = highlight_repository.all end def show @@ -11,7 +11,7 @@ class Management::HighlightsController < ManagementController end def delete - @highlights = highlight_repository.find_all + @highlights = highlight_repository.all end def create diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index 59cb720fc36173eda9ba0768332ff15b055cc60d..4c6de9d93bc5e37daaf181fa63076625b43d02ae 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -3,7 +3,7 @@ class Management::UsersController < ManagementController before_action :set_roles, only: [:new, :edit] def index - @users = user_repository.find_all + @users = user_repository.all end # GET /users/1 @@ -61,7 +61,7 @@ class Management::UsersController < ManagementController # Use callbacks to share common setup or constraints between actions. def set_user - @user = user_repository.find_by_id params[:id] + @user = user_repository.find params[:id] end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 459c4f54a1d0b7fa82b9c72c612d96a69de2af38..109608f4f9f3840c2d2ad4bd9a38e3b613dc8001 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -3,25 +3,24 @@ class WelcomeController < ApplicationController def index @Carousel = Array.new @General = Array.new - mainPage = repository.for(:mainPage).find_all.first + mainPage = repository.for(:mainPage).all.first @Carousel = mainPage["carousel"].collect do |id| - repository.for(:webLink).find_by_id(id)[0] #orientdb returns a hash inside an array, I want only the hash + repository.for(:webLink).find(id)[0] #orientdb returns a hash inside an array, I want only the hash end @General = mainPage["highlights"].collect do |id| - repository.for(:learning_object).find_by_id(id) + repository.for(:learning_object).find(id) end - @Subjects = repository.for(:subject).find_all.take(8) + @Subjects = repository.for(:subject).all.take(8) @Subjects.delete_if do |subject| if subject.highlights.nil? || subject.highlights.empty? true end end @Subjects.each do |subject| - object = repository.for(:learning_object).find_by_id(subject.highlights.first) - subject['first_highlight'] = object + object = repository.for(:learning_object).find(subject.highlights.first) end end diff --git a/app/repositories/active_record/carousel_repository.rb b/app/repositories/active_record/carousel_repository.rb index bfec616aa00ec56993f360f1f7cc03b22d12133c..b1a400103c2ec505822c41a9b8b0ddbd0c9ed05b 100644 --- a/app/repositories/active_record/carousel_repository.rb +++ b/app/repositories/active_record/carousel_repository.rb @@ -1,10 +1,10 @@ module ActiveRecord class CarouselRepository - def find_all + def all end - def find_by_id + def find end def insert_data(name, url) diff --git a/app/repositories/active_record/learning_object_repository.rb b/app/repositories/active_record/learning_object_repository.rb index 66a3d4ea20afc0bacc80dbe47589defee4f0b22d..3d8805867d95740caaeb35bb8187b49670d410cb 100644 --- a/app/repositories/active_record/learning_object_repository.rb +++ b/app/repositories/active_record/learning_object_repository.rb @@ -1,10 +1,10 @@ module ActiveRecord class LearningObjectRepository - def find_all + def all end - def find_by_id + def find end def insert_data(name, url) diff --git a/app/repositories/active_record/main_page_repository.rb b/app/repositories/active_record/main_page_repository.rb index 656aab684c7eaa33e845387038aee21882f2615f..b77b250f6ac4fc585e550c2ce978d201bdb30b68 100644 --- a/app/repositories/active_record/main_page_repository.rb +++ b/app/repositories/active_record/main_page_repository.rb @@ -1,10 +1,10 @@ module ActiveRecord class MainPageRepository - def find_all + def all end - def find_by_id + def find end def insert_data(name, url) diff --git a/app/repositories/active_record/subject_repository.rb b/app/repositories/active_record/subject_repository.rb index dcccbb258a48790ca63d82e9de706190b23480f3..aee7ffc772416678fee52ae3f5c342dca904408f 100644 --- a/app/repositories/active_record/subject_repository.rb +++ b/app/repositories/active_record/subject_repository.rb @@ -1,10 +1,10 @@ module ActiveRecord class SubjectRepository - def find_all + def all end - def find_by_id + def find end def insert_data(name, url) diff --git a/app/repositories/active_record/weblink_repository.rb b/app/repositories/active_record/weblink_repository.rb index a717c04fd8f450ca3d0e531ee82075d8614bde0e..580d4875422ad2e69209b81958857964210c0f5d 100644 --- a/app/repositories/active_record/weblink_repository.rb +++ b/app/repositories/active_record/weblink_repository.rb @@ -1,10 +1,10 @@ module ActiveRecord class WeblinkRepository - def find_all + def all end - def find_by_id + def find end def insert_data(name, url) diff --git a/app/repositories/orient_db/base.rb b/app/repositories/orient_db/base.rb index 349ff82fd3f7c1c418682e5bb6b620d7280fc57e..f55efd042c6375bae4b1d0a07ada60fffea82153 100644 --- a/app/repositories/orient_db/base.rb +++ b/app/repositories/orient_db/base.rb @@ -9,22 +9,22 @@ class OrientDb::Base @connection end - def find_by_id(id) + def find(id) result = get_by_rid(id) build_object result end # Example: - # list = repository.for(:learning_objects).find_all + # list = repository.for(:learning_objects).all # list.each do |learning_object| # learning_object.inspect <LearningObject model> # end - def find_all + def all objects_hash = connection.query "SELECT FROM #{odb_class}", :limit => -1 objects = build_objects(objects_hash) || [] end - def find_all_from_offset_to_limit(offset,limit) + def all_from_offset_to_limit(offset,limit) objects_hash = connection.query "SELECT FROM #{odb_class} SKIP #{offset}", :limit => limit objects = build_objects(objects_hash) || [] end diff --git a/app/repositories/orient_db/carousel_repository.rb b/app/repositories/orient_db/carousel_repository.rb index cf39aa0748c95cf833c983d7cb2b01cc5730e4c7..6cd3d1cf978304b1b3e1ee6fe360d091e8381138 100644 --- a/app/repositories/orient_db/carousel_repository.rb +++ b/app/repositories/orient_db/carousel_repository.rb @@ -1,11 +1,11 @@ module OrientDb class CarouselRepository < Base - def find_all + def all connection.query "SELECT FROM Carousel" end - def find_by_id(id) + def find(id) connection.query "SELECT FROM Carousel where @rid = '#{id}'" end diff --git a/app/repositories/orient_db/highlight_repository.rb b/app/repositories/orient_db/highlight_repository.rb index 046f724c400c0c75f1314c937999432d4cbb6936..df41d9764e042a2551f42bf0a916187ac6400662 100644 --- a/app/repositories/orient_db/highlight_repository.rb +++ b/app/repositories/orient_db/highlight_repository.rb @@ -1,7 +1,7 @@ module OrientDb class HighlightRepository < Base - def find_all + def all connection.query "Select highlights FROM MainPage" end diff --git a/app/repositories/orient_db/main_page_repository.rb b/app/repositories/orient_db/main_page_repository.rb index 3663b56d481e6f1a0af7d6460d4fb228709af896..31e51a02ace50fad43e8c928dad1065fe2ac61a0 100644 --- a/app/repositories/orient_db/main_page_repository.rb +++ b/app/repositories/orient_db/main_page_repository.rb @@ -1,11 +1,11 @@ module OrientDb class MainPageRepository < Base - def find_all + def all connection.query "SELECT FROM MainPage" end - def find_by_id(id) + def find(id) connection.query "SELECT FROM MainPage where @rid = '#{id}'" end diff --git a/app/repositories/orient_db/weblink_repository.rb b/app/repositories/orient_db/weblink_repository.rb index 4141dc96de6761ccfe87e0d0e7da4d40c3691ff7..5e0c8e1bbe849a91deca56139dbd623588b52083 100644 --- a/app/repositories/orient_db/weblink_repository.rb +++ b/app/repositories/orient_db/weblink_repository.rb @@ -1,11 +1,11 @@ module OrientDb class WeblinkRepository < Base - def find_all + def all connection.query "SELECT FROM WebLink" end - def find_by_id(id) + def find(id) connection.query "SELECT FROM WebLink where @rid = '#{id}'" end diff --git a/lib/tasks/mainPage.rake b/lib/tasks/mainPage.rake index 69f84cb36e8a8dace047d8321cbfec20366bcf3b..28340ebb86146c1bd67f767e7020207ff13a4607 100644 --- a/lib/tasks/mainPage.rake +++ b/lib/tasks/mainPage.rake @@ -4,7 +4,7 @@ namespace :mainPage do repository = Portalmec::Application.repository puts 'Generate the main page subject highlights' general_highlights = Array.new - subjects = repository.for(:subject).find_all + subjects = repository.for(:subject).all subjects.each do |subject| # select all the learning objects about that subject objects = subject.learning_objects @@ -26,7 +26,7 @@ namespace :mainPage do end end puts 'Generating the main page highlights' - mainPage = repository.for(:mainPage).find_all.first + mainPage = repository.for(:mainPage).all.first rid = mainPage['@rid'] repository.for(:mainPage).update(rid,'set','highlights','[]') general_highlights.each do |general_highlight| diff --git a/lib/tasks/orientdb.rake b/lib/tasks/orientdb.rake index 3568b65a4c4833f8a5555ec49943557811480bc1..3960b089c79d4eb241ba65c0995d26ddbc2e123c 100644 --- a/lib/tasks/orientdb.rake +++ b/lib/tasks/orientdb.rake @@ -25,7 +25,7 @@ namespace :orientdb do begin # Get LearningObjects from OrientDB (from offset to offset+limit) - learning_objects = lo_repo.find_all_from_offset_to_limit(offset,limit) + learning_objects = lo_repo.all_from_offset_to_limit(offset,limit) rescue # Sleeps for a while to wait database's recovery sleep(30.seconds)