Update journal_papers_controller.rb

This commit is contained in:
chiu 2019-10-31 11:17:05 +08:00
parent da6eee058c
commit 993333280a
1 changed files with 30 additions and 0 deletions

View File

@ -10,6 +10,36 @@ class Admin::JournalPapersController < OrbitMemberController
before_action :need_access_right before_action :need_access_right
before_action :allow_admin_only, :only => [:index, :setting] before_action :allow_admin_only, :only => [:index, :setting]
def merge 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 end
def index def index
@writing_journals = JournalPaper.order_by(:year=>'desc').page(params[:page]).per(10) @writing_journals = JournalPaper.order_by(:year=>'desc').page(params[:page]).per(10)