From 325b84545ca09911df0bf80a7233b339aba755ed Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Thu, 27 Oct 2011 13:12:12 +0500 Subject: [PATCH] don't count expired snippets --- app/models/snippet.rb | 1 + app/views/projects/_top_menu.html.haml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 44cb8887..b67db60b 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -23,6 +23,7 @@ class Snippet < ActiveRecord::Base :length => { :within => 0..10000 } scope :fresh, order("created_at DESC") + scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current]) def self.content_types [ diff --git a/app/views/projects/_top_menu.html.haml b/app/views/projects/_top_menu.html.haml index 59f2533e..0b8751c9 100644 --- a/app/views/projects/_top_menu.html.haml +++ b/app/views/projects/_top_menu.html.haml @@ -23,7 +23,7 @@ = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do Snippets - if @project.snippets.count > 0 - %span{ :class => "top_menu_count" }= @project.snippets.count + %span{ :class => "top_menu_count" }= @project.snippets.non_expired.count - if @commit %span= link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil