Class Transparency
In: app/models/transparency.rb
Parent: Object

Methods

Attributes

announced_streaming  [R] 
featured_photo  [R] 
featured_video  [R] 
grouped_streamings  [R] 
leading_news  [R] 
news_list  [R] 
next4streaming  [R] 
photos_for_carousel  [R] 
secondary_news  [R] 
streaming  [R] 
videos_for_carousel  [R] 

Public Class methods

[Source]

    # File app/models/transparency.rb, line 18
18:   def initialize
19:     # News
20:     documents = News.published.in_irekia.translated.leading.find :all, 
21:       :include => [:organization => :icon], 
22:       :order => "featured DESC, published_at DESC", 
23:       :limit => 15
24: 
25:     @leading_news = documents.shift
26:     @secondary_news = documents.select {|n| n.has_video?("irekia") || n.has_cover_photo? || n.has_photos?("irekia")}[0..3]
27:     @news_list = documents - @secondary_news
28:     # /News
29:     
30:     @featured_video = Video.featured
31:     @videos_for_carousel = Video.published.translated.find :all, 
32:       :conditions => @featured_video ? ["id!=?", @featured_video.id] : nil, 
33:       :limit => 10, 
34:       :order => "published_at DESC"
35:     
36:     # @streaming = StreamFlow.find(:first, :conditions => {:show_in_irekia => true})
37:     # @announced_streaming = StreamFlow.find(:first, :conditions => {:announced_in_irekia => true})
38: 
39:     announced_or_streamed  = []
40:     # announced_or_streamed.push @streaming.event if (@streaming && @streaming.event)
41:     # announced_or_streamed.push @announced_streaming.event if (@announced_streaming && @announced_streaming.event)
42:     # próximo streaming programado: eventos con streaming en OpenIrekia que empiezan dentro de 5 horas o menos
43:     # y no han acabado.
44:     @next4streaming = Event.next4streaming('irekia') - announced_or_streamed
45:     @grouped_streamings = @next4streaming.group_by {|se| se.streaming_status('irekia').to_sym}
46: 
47:         
48:     @grouped_streamings[:live] ||= []
49:     StreamFlow.live().map do |sf| 
50:       if sf.on_air?('irekia')
51:         @grouped_streamings[:live].push sf.event.present? ? sf.event : sf
52:       end
53:     end
54:     @grouped_streamings[:live] = @grouped_streamings[:live].compact.uniq
55:     
56:     
57:     @grouped_streamings[:announced] ||= []
58:     StreamFlow.announced().map do |sf| 
59:       if sf.announced?('irekia')      
60:         @grouped_streamings[:announced].push sf.event.present? ? sf.event : sf
61:       end
62:     end
63:     @grouped_streamings[:announced] = @grouped_streamings[:announced].compact.uniq
64:     
65:     # Foto destacada
66:     # Antes: la primera foto del album más reciente
67:     # @featured_photo = Photo.published.find(:first, :order => "albums.created_at DESC")
68:     # Ahora: la foto de portada del album destacado más reciente
69:     #
70:     falbum = Album.get_featured.first
71:     @featured_photo = falbum.cover_photo if falbum
72: 
73:     # Últimas fotos
74:     # Antes: las de los últimos albumes
75:     #@photos_for_carousel = Photo.published.find(:all, :limit => 10, :order => "albums.created_at DESC")
76:     # Ahora: las portadas de los últimos albumes
77:     @photos_for_carousel = Album.published.with_photos.find(:all, :limit => 10, :conditions => "albums.id != '#{falbum ? falbum.id : '0'}'", :order => "albums.created_at DESC").map {|a| a.cover_photo}
78:   end

Public Instance methods

[Source]

    # File app/models/transparency.rb, line 84
84:   def has_next_streaming?
85:     # grouped_streamings.values.flatten.present? 
86:     (grouped_streamings[:live].to_a+grouped_streamings[:announced].to_a+grouped_streamings[:future].to_a).flatten.present? 
87:   end

[Source]

    # File app/models/transparency.rb, line 80
80:   def has_streaming?
81:     streaming || announced_streaming || next4streaming
82:   end

[Source]

   # File app/models/transparency.rb, line 2
2:   def logger(*args)
3:     ActiveRecord::Base.logger(*args)
4:   end

[Validate]