diff --git a/app/models/tag.rb b/app/models/tag.rb index f19e5f308..c9c324960 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -14,16 +14,34 @@ class Tag for_now = {:start_at=>20.days.ago,:end_at=>Time.now} for_yesterday = {:start_at=>19.days.ago,:end_at=>1.days.ago} + range = self.class.all.collect{ |tag| get_impressionist_diff(tag) } - (get_impressionist_diff - range.min).abs + range.sort!.reverse!.uniq! + offset_size = range.size+4 + section_3 = range.last..range[-(offset_size/4)] + section_2 = range[-(offset_size/4)-1]..range[-2*(offset_size/4)] rescue nil + section_1 = range[-2*(offset_size/4)-1]..range[1] rescue nil + + + case get_impressionist_diff + when range.first + return :heading1 + when section_1 + return :heading2 + when section_2 + return :heading3 + when section_3 + return :heading4 + end + end protected def get_impressionist_diff(item_tag = self) - for_now = item_tag.impressionist_count(:start_date=>20.days.ago,:end_date=>Time.now) - for_yesterday = item_tag.impressionist_count(:start_date=>21.days.ago,:end_date=>1.days.ago) + for_now = item_tag.impressions.where(:created_at.gte=> 20.days.ago,:created_at.lte => Time.now).count + for_yesterday = item_tag.impressions.where(:created_at.gte=> 21.days.ago,:created_at.lte => 1.days.ago).count for_now - for_yesterday end diff --git a/config/initializers/redis_search.rb b/config/initializers/redis_search.rb index f8489b1e4..76971b97c 100644 --- a/config/initializers/redis_search.rb +++ b/config/initializers/redis_search.rb @@ -14,5 +14,5 @@ Redis::Search.configure do |config| # use rmmseg, true to disable it, it can save memroy config.disable_rmmseg = false end -Bulletin.new -NewsBulletin.new \ No newline at end of file +# Bulletin.new +# NewsBulletin.new \ No newline at end of file diff --git a/lib/tasks/matt_dev.rake b/lib/tasks/matt_dev.rake index c19ef3b08..c82606c23 100644 --- a/lib/tasks/matt_dev.rake +++ b/lib/tasks/matt_dev.rake @@ -8,4 +8,40 @@ namespace :matt_dev do p a # p Pinyin.t('台灣不是中國的一部分') 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 diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb index 3cdf1d3d3..c7b31818e 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb @@ -13,7 +13,7 @@