C0 code coverage information

Generated on Fri Aug 25 10:11:25 PDT 2006 with rcov 0.7.0


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
app/controllers/page_controller.rb 577 466
8.0% 
5.8% 
  1 require 'news_parts'
  2 
  3 class PageController < ApplicationController
  4     layout 'site'
  5     session :off
  6     include NewsParts
  7     include ActionView::Helpers::TextHelper
  8     helper :ads
  9     caches_page :home, :index, :news, :best_new_music, :record_reviews, :track_reviews, :features, :features_section, :downloads
 10     
 11     FEATURES_LIST_SELECT_PART = 'id, title, subtitle, artist, image_id, published_at, abstract, sub_category_id, article_pages_data, custom_author, weekly_feature'
 12     
 13     def index
 14         home
 15         render 'home'
 16     end
 17 
 18     def home
 19         @recent_news = News.find_recent(:limit => 2)
 20         # make a list of id's that will not be in the next list
 21         top_news_ids = []
 22         @recent_news.each {|rn| top_news_ids << rn.id }
 23 
 24         blog_conditions = "published_at <= ? AND (type = 'News' OR type = 'NewsBlurb') AND approved = 1"
 25         blog_conditions << " AND id NOT IN (#{top_news_ids.join(", ")})" if top_news_ids.size > 0
 26 
 27         @recent_blogs = Article.find_recent(:limit => 5, :conditions => [blog_conditions, Time.now])
 28 	# increased reviews to 25
 29         @record_reviews = RecordReview.find_recent(
 30             :select => 'id, artist, title, published_at, abstract, image_id, custom_author, author_id, article_pages_data, best_new_music',
 31             :limit => 25,
 32             :include => [:lists, :author])
 33 
 34         @track_reviews = TrackReview.find_recent(
 35             :select => 'id, artist, title, published_at, abstract, image_id, custom_author, alt_image_id, author_id, source',
 36             :limit => 12)
 37 
 38         @features = Feature.find_recent(
 39             :select => 'id, title, artist, subtitle, published_at, abstract, image_id, custom_author, alt_image_id, sub_category_id, author_id, article_pages_data',
 40             :limit => 8)
 41 
 42         @best_new_music = RecordReview.find(
 43             :first,
 44             :select => 'id, artist, title, published_at, best_new_music_featurette, image_id, custom_author, author_id',
 45             :order => 'published_at DESC',
 46             :conditions => 'best_new_music = 1 AND published_at <= NOW() AND approved = 1 ')
 47 
 48         rss_name 'today'
 49 
 50         @page_title = "Home: Pitchfork"
 51         @stylesheets << "home"
 52         @meta_tags = "<meta name=\"description\" content=\"Pitchfork is a website dedicated to music and the discussion thereof. And we rule.\" />"
 53     end
 54 
 55     def record_reviews
 56         if params[:sub_action] == 'more'
 57             three_month_reviews = RecordReview.find(:all, 
 58                 :select => 'id, artist, title, published_at, image_id',
 59                 :order => 'published_at DESC, premiere_position ASC',
 60                 :conditions => ['published_at >= ? AND published_at <= ? AND approved = 1', (Time.now - 3.months), Time.now]
 61                 )
 62             
 63             @total_groups = three_month_reviews.group_by {
 64                  |review| review.published_at.strftime("%Y%m%d")
 65                  }.sort {
 66                       |a, b| b[0]<=>a[0] 
 67                       }
 68                       
 69             @record_review_pages = Paginator.new self, @total_groups.size, 12, params[:page]
 70             @record_review_groups = @total_groups[@record_review_pages.current.first_item - 1...@record_review_pages.current.last_item]
 71             
 72             @page_title = "Pitchfork: More Record Reviews!"
 73         else
 74             recent_reviews = RecordReview.find(
 75                 :all,
 76                 :select => 'id, artist, title, published_at, image_id',
 77                 :order => 'published_at DESC, premiere_position ASC',
 78                 :conditions => ['published_at >= ? AND published_at <= ? AND approved = 1', (Time.now - 11.days), Time.now])
 79                 
 80             unless recent_reviews and recent_reviews.size > 0
 81                 recent_reviews = RecordReview.find(
 82                     :all,
 83                     :select => 'id, artist, title, published_at, image_id',
 84                     :limit => 30,
 85                     :order => 'published_at DESC, premiere_position ASC',
 86                     :conditions => 'published_at <= NOW() AND approved = 1')
 87             end
 88             
 89             @record_review_groups = recent_reviews.group_by {
 90                  |review| review.published_at.strftime("%Y%m%d")
 91                  }.sort {
 92                       |a, b| b[0]<=>a[0] 
 93                       }
 94                       
 95             @record_review_groups = @record_review_groups[0...6]
 96         
 97             @highlights = List.find(1).articles.find(:all,
 98                                                      :select => 'id, artist, title, published_at, image_id, abstract, article_pages_data',
 99                                                      :limit => 3,
100                                                      :conditions => 'published_at <= NOW() AND approved = 1 AND type = \'RecordReview\'',
101                                                      :order => 'RAND()')
102              @essential = RecordReview.find(
103                 :first,
104                 :select => 'id, artist, title, published_at, best_new_music_featurette, image_id, custom_author, author_id',
105                 :order => 'published_at DESC',
106                 :conditions => 'best_new_music = 1 AND published_at <= NOW() AND approved = 1 ')
107                 
108             @this_day = RecordReview.find(
109                 :all,
110                 :select => 'id, artist, title, published_at, image_id, abstract, article_pages_data',
111                 :conditions => 'premiere_position < 3 AND published_at <= NOW() AND approved = 1 AND (MONTH(published_at) = MONTH(CURDATE()) AND DAY(published_at) = DAY(CURDATE()) AND YEAR(CURDATE()) != YEAR(published_at))'
112             )
113             
114             @page_title = "Pitchfork: Record Reviews"
115         end
116         
117         get_most_read('RecordReview') unless read_fragment(:controller => '/article', :action => 'record_review', :part => 'most_read')
118 
119         rss_name 'record_reviews'
120         
121         @stylesheets << "pages"
122         
123         if params[:sub_action] == 'more'
124             render :action => 'more_record_reviews'
125         end
126     end
127 
128     def track_reviews
129         criteria = nil
130         
131         if params[:year] and params[:month]
132             month = params[:month].to_i
133             year = params[:year].to_i
134             day = nil
135             condition = "approved = 1 "
136             if params[:day]
137                 day = params[:day].to_i
138                 criteria = [condition + "AND published_at >= ? AND published_at <= ?", Time.local(year, month, day, 0, 0, 0), Time.now()]
139             else
140                 first_day, last_day = month_spread(year, month) 
141                 criteria = [condition + "AND (published_at >= ? AND published_at <= ? )", first_day, last_day]
142             end
143             @results_title = "#{Date::MONTHNAMES[month]}#{ (" " + day.to_s) if day}, #{year}"
144             @track_reviews = TrackReview.find(:all, :order => 'published_at DESC, premiere_position ASC', :conditions => criteria )
145         elsif params[:genre]
146             criteria = ["genre = ? AND (published_at <= NOW() OR published_at IS NULL) AND approved = 1", params[:genre]]
147             @page_title = "Pitchfork: Track Reviews - #{params[:genre]}"
148         elsif params[:id]
149             begin
150                 item = Article.find(params[:id])
151                 criteria = ["published_at <= ? AND published_at >= ? AND approved = 1", item.published_at,
152                     item.published_at.strftime("%Y-%m-1")]
153                 @page_title = "Pitchfork: #{item.artist}: \"#{strip_tags(item.title)}\" [Track Review]"
154                 item.increment_read
155             rescue ActiveRecord::RecordNotFound
156                 criteria = "published_at <= NOW() AND published_at >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND approved = 1"
157             end
158         else
159             criteria = "published_at <= NOW() AND published_at >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND approved = 1"
160         end
161 
162         unless @track_reviews
163             @tracks_pages, @track_reviews = paginate :track_review, 
164                 :conditions => criteria,
165                 :order => 'published_at DESC, premiere_position, created_at DESC', 
166                 :per_page => 12
167         end
168         
169         @page_title = "Pitchfork: Track Reviews" unless @page_title
170         
171         get_most_read('TrackReview') unless read_fragment(:controller => '/article', :action => 'track_review', :part => 'most_read')
172         
173         unless params[:page] and params[:page].to_i > 1
174             @front = true
175         end
176         
177         rss_name 'track_reviews'
178 		        
179         @meta_tags = "<meta name=\"description\" content=\"Track Reviews: #{Time.now.strftime("%m-%d-%y")}:\n#{ (track_titles =[]; @track_reviews.each {|track| track_titles << "#{strip_tags(track.artist)} - #{strip_tags(track.title)}"}; track_titles.join(";\n"))}\">\n" +
180                      "<meta name=\"keywords\" content=\"#{(track_artists =[]; @track_reviews.each {|track| track_artists << track.artist}; track_artists.join(", "))}\">"
181         
182         @stylesheets << "pages" << "article"
183     end
184 
185     def news
186         # default news conditions
187         criteria = nil
188         archive = false
189         
190         # first lets see if there are any date parameters
191         if params[:year] and params[:month]
192             archive = true
193             month = params[:month].to_i
194             year = params[:year].to_i
195             day = nil
196             first_day, last_day = month_spread(year, month)
197             
198             if params[:day]
199                 archive = false
200                 day = params[:day].to_i
201                 criteria = ["published_at >= ? AND published_at <= ? AND (type ='News' OR type ='NewsBlurb') AND approved = 1", Time.local(year, month, day, 0, 0, 0), Time.local(year, month, day, 23, 59, 59)]
202             else
203                 criteria = "(published_at >= ? AND published_at <= ?) AND published_at <= ? AND (type = 'News' OR type = 'NewsBlurb') AND approved = 1"
204                 criteria = [criteria, first_day, last_day, Time.now]
205             end
206             @results_title = "#{Date::MONTHNAMES[month]}#{ (" " + day.to_s) if day}, #{year}"
207             @date = { :year => year, :month => month }
208             @news_articles = Article.find(:all, :order => 'published_at DESC, premiere_position, created_at DESC', :conditions => criteria )
209         elsif params[:category]
210             tagged_articles = Tag.find_by_name(params[:category]).tagged.delete_if { |item| item.published_at > Time.now or item.approved != 1 }
211             @news_articles = tagged_articles.sort { | a, b | b.published_at <=> a.published_at }
212         elsif params[:id]
213             begin
214                 item = Article.find(params[:id])
215                 criteria = "Published_at <= ? AND published_at >= ? AND published_at <= ? AND (type = 'News' OR type = 'NewsBlurb') AND approved = 1"
216                 criteria = [criteria, item.published_at, item.published_at.strftime("%Y-%m-1"), Time.now]
217                 @news_pages, @news_articles = find_paged_news(criteria)
218                 @page_title = "Pitchfork: " + strip_tags(item.title)
219             rescue ActiveRecord::RecordNotFound
220                 criteria = "Published_at >= ? AND published_at <= ? AND (type = 'News' OR type = 'NewsBlurb') AND approved = 1"
221                 criteria = [criteria, Time.now.ago(1.month), Time.now]
222                 @news_pages, @news_articles = find_paged_news(criteria)
223             end
224         else
225             criteria = "Published_at >= ? AND published_at <= ? AND (type = 'News' OR type = 'NewsBlurb') AND approved = 1"
226             criteria = [criteria, Time.now.ago(1.month), Time.now]
227             @news_pages, @news_articles = find_paged_news(criteria)
228         end
229 
230         unless params[:page] and params[:page].to_i > 1
231             @front = true
232         end
233 
234         #build up the sidebar data
235         current_news(false)
236         
237         # setup the standart page stuff (title, rss, etc...)
238         setup_page
239         
240         @meta_tags = "<meta name=\"description\" content=\"News: #{Time.now.strftime("%m-%d-%y")}:\n#{ (news_titles =[]; @news_articles.each {|news| news_titles << strip_tags(news.title)}; news_titles.join(";\n"))}\">\n" +
241                     "<meta name=\"keywords\" content=\"#{(news_artists =[]; @news_articles.each {|news| news_artists << news.artist}; news_artists.join(", "))}\">"
242 
243         @stylesheets << "pages" << "article"
244         
245         render :template => '/page/news_archive' if archive
246     end
247     
248     def news_category
249     end
250 
251     def features
252         if params[:sub_action] and params[:sub_action] = 'more'
253             @article_pages, @articles =  paginate(
254                 :features,
255                 :order => 'published_at DESC',
256                 :include => [:sub_category, :image],
257                 :per_page => 12,
258                 :conditions => 'published_at <= NOW() AND approved = 1')
259         else
260             # find the top Weekly.
261             top_week_feature = Feature.find(
262                 :first,
263                 :order => 'weekly_feature DESC, published_at DESC',
264                 :include => [:sub_category, :image],
265                 :limit => 1,
266                 :conditions => 'published_at <= NOW() AND approved = 1')
267 
268             # now add the remaining features
269             @features = Feature.find(
270                     :all,
271                     :order => 'published_at DESC',
272                     :limit => 4,
273                     :conditions => "published_at <= NOW() AND approved = 1 AND id NOT IN (#{ top_week_feature.id })")
274 
275             #insert top weekly into array
276             @features.insert(0, top_week_feature)
277 
278             # reset the exclusions
279             exclude = []
280             @features.each { |feat| exclude << feat.id.to_s }
281             
282             # sub_categories and type are redundant in the Conditions, 
283             # but want to make clear athat a wrong type didn't accidentally get added somehow
284             think_query = "weekly_feature = 1 AND published_at <= NOW() AND approved = 1"
285             interviews_query = "sub_category_id = 3 AND published_at <= NOW() AND approved = 1"
286             live_query = "sub_category_id = 2 AND published_at <= NOW() AND approved = 1"
287             column_query = "sub_category_id = 4 AND published_at <= NOW() AND approved = 1"
288             
289             if exclude and exclude.size > 0
290                 exclude_list = exclude.join(', ')
291                 exclude_list = " AND articles.id NOT IN (#{ exclude_list })"
292                 think_query << exclude_list
293                 
294                 @think_pieces = Feature.find(
295                     :all,
296                     :order => 'published_at DESC',
297                     :limit => 3,
298                     :conditions => think_query)
299                 
300                 #add think pieces to the exclusion so you dont' have repeats elsewhere.
301                 @think_pieces.each { |feat| exclude << feat.id.to_s }
302                 exclude_list = exclude.join(', ')
303                 exclude_list = " AND id NOT IN (#{ exclude_list })"
304                 
305                 interviews_query << exclude_list
306                 live_query << exclude_list
307                 column_query << exclude_list
308             else
309                 @think_pieces = Feature.find(
310                     :all,
311                     :order => 'published_at DESC',
312                     :limit => 3,
313                     :conditions => think_query)
314             end
315             
316             @interviews = Feature.find(
317                     :all,
318                     :order => 'published_at DESC',
319                     :limit => 3,
320                     :conditions => interviews_query)
321 
322             @live_review = Feature.find(
323                     :first,
324                     :order => 'published_at DESC',
325                     :conditions => live_query)
326 
327             @column = Feature.find(
328                     :first,
329                     :order => 'published_at DESC',
330                     :conditions => column_query)
331         end
332     
333         get_most_read('Feature') unless read_fragment(:controller => '/article', :action => 'feature', :part => 'most_read')
334         @is_features = true
335         rss_name 'features'
336              
337         @page_title = "Pitchfork: Features"
338         @stylesheets << "pages"
339         render :template => '/search/features' if params[:sub_action] and params[:sub_action] = 'more'
340     end
341     
342     def feature_section
343         case params[:sub_action]
344         when 'highlights'
345             @category_id = 0
346             @results_title = "Feature Highlights"
347         when 'weekly'
348             # okay this is weird. I know.
349             # but currently this will never be hit.
350             # probably should remove this condition.
351             # @category_id = SubCategory.find(:first, :conditions => "short_title = 'Story'").id
352             @category_id = 1
353             @results_title = "Weekly Features"
354         when 'interviews'
355             @category_id = SubCategory.find(:first, :conditions => "short_title = 'Interview'").id
356             @results_title = "Interviews"
357         when 'live'
358             @category_id = SubCategory.find(:first, :conditions => "short_title = 'Live'").id
359             @results_title = "Live Reviews"
360         when 'columns'
361             @category_id = SubCategory.find(:first, :conditions => "short_title = 'Column'").id
362             @results_title = "Columns"
363         when 'artists'
364             @category_id = SubCategory.find(:first, :conditions => "short_title = 'Artist List'").id
365             @results_title = "Artists' Lists"
366         when 'staff'
367             @category_id = SubCategory.find(:first, :conditions => "short_title = 'Staff List'").id
368             @results_title = "Staff Lists"
369         end
370         
371         if @category_id == 0
372             @article_pages, @articles = paginate( :features,
373                                                 :per_page => 12,
374                                                 :order => 'articles.published_at DESC',
375                                                 :select => 'articles.*',
376                                                 :joins => 'LEFT JOIN articles_lists ON articles.id = articles_lists.article_id',
377                     :conditions => 'articles.published_at <= NOW() AND articles.approved = 1 AND articles_lists.list_id = 5 AND type = \'Feature\'')
378         elsif @category_id == 1
379             @article_pages, @articles = paginate( :features, :per_page => 12, 
380                                                    :order => 'published_at DESC', 
381                                                    :conditions => 'weekly_feature = 1 AND (published_at <= NOW() OR published_at IS NULL) AND approved = 1')
382         else
383             @article_pages, @articles = paginate( :features, :per_page => 12, 
384                                                   :order => 'published_at DESC', 
385                                                   :conditions => ['(sub_category_id = ? AND published_at <= NOW() OR published_at IS NULL) AND approved = 1', @category_id])
386         end
387         
388         get_most_read('Feature') unless read_fragment(:controller => '/article', :action => 'feature', :part => 'most_read')
389         
390         rss_name 'features'
391              
392         @is_features = true
393         @page_title = "Pitchfork: Features - #{@results_title}"
394         @stylesheets << "pages"        
395         render :template => '/search/features'
396     end
397     
398     def best_new_music
399         if params[:sub_action] and params[:sub_action] != ""
400             case params[:sub_action]
401             when 'current'
402                 @best_new_music_pages, @best_new_music = paginate(
403                     :record_reviews,
404                     :per_page => 12,
405                     :select => 'id, artist, title, record_label, release_year, reissue_label, reissue_year, rating, published_at, best_new_music_featurette, image_id',
406                     :order => 'published_at DESC',
407                     :conditions => "best_new_music = 1 AND (published_at >= #{ Time.now.month > 9 ? "'1/1/#{Time.now.year}'": "DATE_SUB(CURDATE(), INTERVAL 9 MONTH)"} " +
408                                     "AND published_at <= NOW()) AND approved = 1")
409             when 'more'
410                 @best_new_music_pages, @best_new_music = paginate(
411                     :record_reviews,
412                     :per_page => 12,
413                     :select => 'id, artist, title, record_label, release_year, reissue_label, reissue_year, rating, published_at, best_new_music_featurette, image_id',
414                     :order => 'published_at DESC',
415                     :conditions => "best_new_music = 1 AND published_at <= NOW() AND approved = 1")
416             when 'current_recommendations'
417                 @article_pages, @articles = paginate(
418                     :record_reviews,
419                     :per_page => 12,
420                     :order => 'published_at DESC',
421                     :select => "id, artist, title, published_at, abstract, image_id, article_pages_data",
422                     :join => 'LEFT JOIN articles_lists ON articles.id = articles_lists.article_id',
423                     :conditions => "articles_lists.list_id = 6 AND (published_at >= #{ Time.now.month > 9 ? "'1/1/#{Time.now.year}'": "DATE_SUB(CURDATE(), INTERVAL 9 MONTH)"} " +
424                                     "AND published_at <= NOW() AND approved = 1)")
425             when 'more_recommendations'
426                 @article_pages, @articles = paginate(
427                     :record_reviews,
428                     :per_page => 12,
429                     :order => 'published_at DESC',
430                     :select => "id, artist, title, published_at, abstract, image_id, article_pages_data",
431                     :join => 'LEFT JOIN articles_lists ON articles.id = articles_lists.article_id',
432                     :conditions => "articles_lists.list_id = 6 AND published_at <= NOW() AND approved = 1")
433             else
434                 bnm_by_year(params[:year] || params[:id])
435             end
436 
437             bnm_simple_recent
438         elsif params[:year] and params[:year] != ""
439             bnm_by_year(params[:year])
440             bnm_simple_recent
441         else
442             @best_new_music = RecordReview.find(
443             :all,
444             :order => 'published_at DESC',
445             :select => 'id, artist, title, record_label, release_year, reissue_label, reissue_year, rating, published_at, best_new_music_featurette, image_id',
446             :limit => 3,
447             :conditions => 'best_new_music = 1 AND (published_at <= NOW() OR published_at IS NULL) AND approved = 1')
448         
449             @highlights = List.find(6).articles.find(:all,
450                                                     :limit => 6,
451                                                     :select => "id, artist, title, published_at, abstract, image_id",
452                                                     :order => 'published_at DESC',
453                                                     :conditions => 'type = \'RecordReview\' AND (published_at <= NOW() OR published_at IS NULL) AND approved = 1')
454             exclude = []
455             @best_new_music.each { |bnm| exclude << bnm.id.to_s }
456             
457             if exclude and exclude.size > 0
458                 @recent = RecordReview.find(
459                 :all,
460                 :order => 'published_at DESC',
461                 :select => 'id, artist, title, image_id',
462                 :limit => 4,
463                 :conditions => "best_new_music = 1 AND published_at >= SUBDATE(CURDATE(), INTERVAL 3 MONTH) AND " +
464                                 "(published_at <= NOW() OR published_at IS NULL) AND approved = 1 AND id NOT IN (#{ exclude.join(', ') })")
465             else
466                 @recent = []
467             end
468         end
469         
470         rss_name'best_new_music'
471         
472         @stylesheets << "pages"
473         
474         if params[:sub_action]
475             case params[:sub_action]
476             when 'current_recommendations'
477                 @page_title = "Pitchfork: Current Recommendations"
478                 render :action => 'recommendations'
479             when 'more_recommendations'
480                 @page_title = "Pitchfork: More Recommendations"
481                 render :action => 'recommendations'
482             when 'current'
483                 @page_title = "Pitchfork: Current Best New Music"
484                 render :action => 'best_new_music_year'
485             when 'more'
486                 @page_title = "Pitchfork: More Best New Music"
487                 render :action => 'best_new_music_year'
488             else
489                 @page_title = "Pitchfork: Best New Music #{params[:id]}"
490                 render :action => 'best_new_music_year'
491             end
492         elsif params[:year]
493             @page_title = "Pitchfork: Best New Music #{params[:year]}"
494              render :action => 'best_new_music_year'
495         else
496             @page_title = "Pitchfork: Best New Music"
497         end
498     end
499 
500     def downloads
501         @download_pages, @downloads = paginate :downloads, 
502             :conditions => "(published_at <= NOW() OR published_at IS NULL) AND approved = 1",
503             :order => 'pin_article DESC, published_at DESC, premiere_position', 
504             :per_page => 12
505             
506 		current_news(false)        
507         
508         rss_name 'downloads'
509 		
510 		@page_title = "Pitchfork: Free Downloads"
511         @stylesheets << "pages" 
512     end
513     
514     def staff
515         @page_title = "Pitchfork: Staff"
516         
517         get_most_read('RecordReview') unless read_fragment(:controller => '/article', :action => 'record_review', :part => 'most_read')
518 
519         rss_name 'record_reviews'
520 		        
521         @stylesheets << "pages"
522     end
523     
524     def ad
525         @page_title = "Pitchfork: Advertising"
526         
527         get_most_read('RecordReview') unless read_fragment(:controller => '/article', :action => 'record_review', :part => 'most_read')
528 
529         rss_name 'record_reviews'
530         
531         @stylesheets << "pages"
532     end
533     
534     def contact
535         @page_title = "Pitchfork: Contact"
536         
537         get_most_read('RecordReview') unless read_fragment(:controller => '/article', :action => 'record_review', :part => 'most_read')
538 
539 		rss_name 'record_reviews'
540         
541         @stylesheets << "pages"
542     end
543 
544     def help
545         @page_title = "Pitchfork: Help"
546         
547         get_most_read('RecordReview') unless read_fragment(:controller => '/article', :action => 'record_review', :part => 'most_read')
548 
549 		rss_name 'record_reviews'
550         
551         @stylesheets << "pages"
552     end
553     
554     private
555     
556     def bnm_by_year(year)
557         @best_new_music_pages, @best_new_music = paginate(
558             :record_reviews,
559             :per_page => 12,
560             :order => 'published_at DESC, premiere_position, created_at DESC',
561             :select => 'id, artist, title, record_label, release_year, reissue_label, reissue_year, rating, published_at, best_new_music_featurette, image_id',
562             :conditions => ["best_new_music = 1 AND (published_at >= ? AND published_at <= ?) AND published_at <= NOW() AND approved = 1", 
563                 Date.parse("1/1/" + year),
564                 Date.parse("12/31/" + year)])
565     end
566     
567     def bnm_simple_recent
568         @recent = RecordReview.find(
569             :all,
570             :order => 'RAND()',
571             :limit => 4,
572             :select => 'id, artist, title, image_id',
573             :conditions => "best_new_music = 1 AND published_at >= SUBDATE(CURDATE(), INTERVAL 2 MONTH) AND " +
574                             "(published_at <= NOW() OR published_at IS NULL) AND approved = 1")
575     end
576     
577 end

Generated using the rcov code coverage analysis tool for Ruby version 0.7.0.

Valid XHTML 1.0! Valid CSS!