Commit c000d282 by tady

flow viewにTagを表示

parent 83db9837
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4' gem 'rails', '~> 4'
......
...@@ -29,6 +29,17 @@ class Tag < ActiveRecord::Base ...@@ -29,6 +29,17 @@ class Tag < ActiveRecord::Base
having('posts_count > 0') having('posts_count > 0')
} }
class << self
# 最近投稿されたTagを取得
def recent(limit=10)
Post.recent(20).map do |post|
post.tags
end.flatten.compact.uniq.take(limit)
end
end
def recent_posts(limit = 30) def recent_posts(limit = 30)
self.posts.recent(limit) self.posts.recent(limit)
end end
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
h2.panel-title 最近投稿したユーザー(調整中) h2.panel-title 最近投稿されたタグ
.panel-body.list-group .panel-body.list-group
- User.post_recently.limit(10).each_with_index do |author, i| - Tag.recent(10).each_with_index do |tag, i|
a.list-group-item.post-list data-author-id=author.id href=search_path(q: "@#{author.nickname}") = "#{author.name} (@#{author.nickname})" a.list-group-item data-tag-id=tag.id href=search_path(q: "##{tag.name}") = "#{tag.name} (#{tag.posts_count})"
#! /bin/sh
ssh rendezvous "cd /tmp; mysqldump -urendezvous -pedc08630b029fc979af5fd9e8fd979f690b0be149bac465bd66c2456c8fcd651 rendezvous > rendezvous.`date +'%Y%m%d'`.sql;"; scp rendezvous:/tmp/rendezvous.`date +'%Y%m%d'`.sql ./backup/
...@@ -3,7 +3,9 @@ namespace :batch do ...@@ -3,7 +3,9 @@ namespace :batch do
desc 'Tagに関連するPostのcounter_cacheの再生成' desc 'Tagに関連するPostのcounter_cacheの再生成'
task reset_counters: :environment do task reset_counters: :environment do
puts "\t[START] batch:reset_counters"
Tag.all.each{|t| Tag.reset_counters(t.id, :posts) } Tag.all.each{|t| Tag.reset_counters(t.id, :posts) }
puts "\t[FINISH] batch:reset_counters"
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment