cache user promotion report

This commit is contained in:
r888888888
2013-06-21 16:52:59 -07:00
parent cb469a75bf
commit ef2faff245
2 changed files with 13 additions and 9 deletions

View File

@@ -23,7 +23,9 @@ module Reports
end end
def users def users
User.with_timeout(30_000) do
User.joins(:posts).where("users.level < ?", User::Levels::CONTRIBUTOR).where("posts.created_at >= ? and posts.fav_count >= 1", self.class.min_time).order("users.name") User.joins(:posts).where("users.level < ?", User::Levels::CONTRIBUTOR).where("posts.created_at >= ? and posts.fav_count >= 1", self.class.min_time).order("users.name")
end end
end end
end end
end

View File

@@ -15,6 +15,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% cache("user-promotions-report/#{Date.today}") do %>
<% @report.users.each do |user| %> <% @report.users.each do |user| %>
<tr> <tr>
<td><%= link_to user.name, user_path(user) %></td> <td><%= link_to user.name, user_path(user) %></td>
@@ -24,6 +25,7 @@
<td><%= number_to_percentage Reports::UserPromotions.confidence_interval_for(user, 10), :precision => 0 %></td> <td><%= number_to_percentage Reports::UserPromotions.confidence_interval_for(user, 10), :precision => 0 %></td>
</tr> </tr>
<% end %> <% end %>
<% end %>
</tbody> </tbody>
</table> </table>
</div> </div>