Method: SpudPost.months_with_public_blog_posts

Defined in:
app/models/spud_post.rb

.months_with_public_blog_postsObject



93
94
95
96
97
98
99
100
# File 'app/models/spud_post.rb', line 93

def self.months_with_public_blog_posts
	records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ? AND is_news = ?', true, DateTime.now, false).group('published_month, published_year').order('published_year desc, published_month desc')
	begin
		return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
	rescue Exception => e
		logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
	end
end