From 5e83ea8b3ccb275c25a44ca6e944996f75376bd3 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Tue, 4 Oct 2016 14:00:30 +0300 Subject: [PATCH] Export only this year's talk preferences --- app/controllers/home_controller.rb | 3 +-- app/models/talk_preference.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 8f61789..7d1be76 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -9,8 +9,7 @@ class HomeController < ApplicationController end def export - @talks = Talk.find(:all, from: :halfnarp_friendly) - @talk_preferences = TalkPreference.all + @talk_preferences = TalkPreference.this_years end def conflicts diff --git a/app/models/talk_preference.rb b/app/models/talk_preference.rb index fe68f93..957d595 100644 --- a/app/models/talk_preference.rb +++ b/app/models/talk_preference.rb @@ -13,6 +13,11 @@ class TalkPreference < ActiveRecord::Base ids.all? { |id| include? id } end + def self.this_years + timespan = Time.now.change(month: 1, day: 1, hour: 0)..Time.now.change(month: 12, day: 1, hour: 0) + where created_at: timespan + end + private def assign_new_unique_id