Commit 325b84545ca09911df0bf80a7233b339aba755ed
1 parent
000c0324
Exists in
master
and in
4 other branches
don't count expired snippets
Showing
2 changed files
with
2 additions
and
1 deletions
Show diff stats
app/models/snippet.rb
| @@ -23,6 +23,7 @@ class Snippet < ActiveRecord::Base | @@ -23,6 +23,7 @@ class Snippet < ActiveRecord::Base | ||
| 23 | :length => { :within => 0..10000 } | 23 | :length => { :within => 0..10000 } |
| 24 | 24 | ||
| 25 | scope :fresh, order("created_at DESC") | 25 | scope :fresh, order("created_at DESC") |
| 26 | + scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current]) | ||
| 26 | 27 | ||
| 27 | def self.content_types | 28 | def self.content_types |
| 28 | [ | 29 | [ |
app/views/projects/_top_menu.html.haml
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do | 23 | = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do |
| 24 | Snippets | 24 | Snippets |
| 25 | - if @project.snippets.count > 0 | 25 | - if @project.snippets.count > 0 |
| 26 | - %span{ :class => "top_menu_count" }= @project.snippets.count | 26 | + %span{ :class => "top_menu_count" }= @project.snippets.non_expired.count |
| 27 | 27 | ||
| 28 | - if @commit | 28 | - if @commit |
| 29 | %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 | 29 | %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 |