From 56cc729b43448e38ad2bc535c74174d38638656d Mon Sep 17 00:00:00 2001 From: IJ Kim Date: Wed, 5 Oct 2022 11:09:29 -0400 Subject: [PATCH] added RegEvent#active_since_past_year --- lib/sf/reg_event.rb | 7 +++++++ lib/sf/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/sf/reg_event.rb b/lib/sf/reg_event.rb index 1e73db4..bb7a112 100644 --- a/lib/sf/reg_event.rb +++ b/lib/sf/reg_event.rb @@ -48,6 +48,13 @@ def self.by_codes(codes = []) sobjects.blank? ? [] : build_collection(sobjects) end + def self.active_since_past_year + year_ago = Time.now.years_ago(1).iso8601 + where = "status__c = 'active' and end_date__c > #{year_ago}" + sobjects = Sf.client.query("select #{FIELDS_SELECT_STR} from RegEvent__c where #{where}") + sobjects.blank? ? [] : build_collection(sobjects) + end + def self.create_from_event(event) return if event.nil? || event.id.nil? || !event.instance_of?(Event) diff --git a/lib/sf/version.rb b/lib/sf/version.rb index 2a859d2..2631401 100644 --- a/lib/sf/version.rb +++ b/lib/sf/version.rb @@ -1,3 +1,3 @@ module Sf - VERSION = "0.1.70" + VERSION = "0.1.71" end