compact fix
This commit is contained in:
@@ -107,18 +107,21 @@ class Neuigkeit < ActiveRecord::Base
|
||||
def is_event?
|
||||
self.has_calentries?
|
||||
end
|
||||
def relevant_calentry
|
||||
self.calentries.min_by{|c| c.days_to_today * 2 * ((c.is_past?)? 2:1)}
|
||||
end
|
||||
def update_cache
|
||||
if self.has_meeting? && !self.meeting.calentry.nil?
|
||||
self.update_column(:cache_order, (self.meeting.calentry.start.to_date - Date.today).to_i.abs)
|
||||
self.update_column(:cache_order, (self.meeting.calentry.start.to_date - Date.today).to_i.abs * 2)
|
||||
self.update_column(:cache_relevant_date, self.meeting.calentry.start.to_date)
|
||||
else
|
||||
if self.is_event?
|
||||
c = self.calentries.min{|c| c.days_to_today * ((c.is_past?)? 2:1)}
|
||||
self.update_column(:cache_order, c.days_to_today * ((c.is_past?)? 2:1))
|
||||
c = self.calentries.min_by{|c| c.days_to_today * 2 * ((c.is_past?)? 2:1)}
|
||||
self.update_column(:cache_order, c.days_to_today * 2 * ((c.is_past?)? 2:1))
|
||||
self.update_column(:cache_relevant_date, (c.is_past?) ? c.ende.to_date : c.start.to_date)
|
||||
else
|
||||
unless self.datum.nil?
|
||||
self.update_column(:cache_order, (((self.datum.to_date - Date.today).to_i)/3).abs-1)
|
||||
self.update_column(:cache_order, (((self.datum.to_date - Date.today).to_i)).abs)
|
||||
self.update_column(:cache_relevant_date, self.datum.to_date)
|
||||
else
|
||||
self.update_column(:cache_order,0)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<% if neuigkeit.has_calentries? %>
|
||||
<div class="pull-right" href="#">
|
||||
<%= fa_icon("calendar 2x") %>
|
||||
<%= neuigkeit.calentries.min{|c| c.days_to_today * ((c.is_past?)? 2:1)}.text %>
|
||||
<%= neuigkeit.relevant_calentry.text %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user