Orbit/lib/tasks/matt_dev.rake

61 lines
1.9 KiB
Ruby

# encoding: UTF-8
namespace :matt_dev do
desc 'Testing Searching'
task :searching_01 => :environment do
a= Redis::Search.query("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false})
p a
a= Redis::Search.query("NewsBulletin",'社科院',:conditions =>{:is_checked=>true,:is_hidden=>false})
p a
end
task :searching_02 => :environment do
a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false})
fulltext '關島'
with(:frontend_search,true)
#with(:is_hidden,true)
end
p a.results
a= NewsBulletin.solr_search do #("NewsBulletin",'社科院',:conditions =>{:is_checked=>true,:is_hidden=>false})
fulltext '社科院'
with(:frontend_search,true)
#with(:is_hidden,true)
end
p a.results
end
task :testing_new_tag_cal do
ranges = [[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5],[1,2,3,4,5,6],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7,8],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10,11],[1,2,3,4,5,6,7,8,9,10,11,12],[-1,-2,-3,-4,5,6,7,8,9,10,11,12]]
ranges.each{ |range|
cal(range)
}
end
def cal(range_t)
range = range_t.sort.reverse
puts '='*20
puts range.to_s
puts '='*20
offset_size = range.size+4
section_3 = range.last..range[-(offset_size/4)]
puts(section_3)
section_2 = range[-(offset_size/4)-1]..range[-2*(offset_size/4)] rescue nil
puts(section_2)
section_1 = range[-2*(offset_size/4)-1]..range[1] rescue nil
puts(section_1)
range.each{|num|
result= case num
when range.first
:heading1
when section_1
:heading2
when section_2
:heading3
when section_3
:heading4
end
puts "Num:#{num} Result: #{result}"
}
puts("END")
end
end