diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index a116c94..6ccf871 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -10,6 +10,36 @@ class Admin::JournalPapersController < OrbitMemberController before_action :need_access_right before_action :allow_admin_only, :only => [:index, :setting] def merge + @journals=JournalPaper.order_by(:year=>'desc').map{|value| value}.group_by{|v| [v[:paper_title],v[:journal_title]]} + @journals.each do |key,value| + if value.length==1 + @journals.except! key + end + end + #journals = JournalPaper.order_by(:year=>'desc').map{|value| value} + #journals_name1 = journals.map{|value| value[:paper_title]} + #journals_name2 = journals.map{|value| value[:journal_title]} + #compare1 = journals_name1.map{|v1| journals_name1.select{|v2| v2==v1}.count>1} + #compare2 = journals_name2.map{|v1| journals_name2.select{|v2| v2==v1}.count>1} + #compare = compare1 and compare2 + #@journal = Hash.new + #compare.each_with_index do |b,i| + # if b && !(@journal.keys.include? [journals_name1[i],journals_name2[i]]) + # @journal[[journals_name1[i],journals_name2[i]]] = [journals[i]] + # elsif b + # @journal[[journals_name1[i],journals_name2[i]]] << journals[i] + # end + #end + if params['mode']!='simple' + @journals.each do |key,value| + value = value.group_by{|v| [v[:level_type],v[:author_type],v[:paper_type],v[:publication_date]]} + value.each do |key1,value1| + if value1.length==1 + value.except! key1 + end + end + end + end end def index @writing_journals = JournalPaper.order_by(:year=>'desc').page(params[:page]).per(10)