From c7e8d53e60be1ff7e89e5293086e6f195ec55254 Mon Sep 17 00:00:00 2001 From: IJ Kim Date: Tue, 14 Mar 2017 22:28:39 -0400 Subject: [PATCH] included reg_items in the checkin query --- lib/sf/reg_registration.rb | 16 +++++++++++----- lib/sf/version.rb | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/sf/reg_registration.rb b/lib/sf/reg_registration.rb index 35f9f8a..fb70006 100644 --- a/lib/sf/reg_registration.rb +++ b/lib/sf/reg_registration.rb @@ -135,31 +135,31 @@ def self.all_processed(code) def self.all_checked_in(code) where_stmt = "event_code__c = \'#{code}\' and check_in_at__c != null" order_stmt = self.order_by(last_name__c: "ASC") - self.query(where_stmt, order_stmt) + self.query_with_reg_item_codes(where_stmt, order_stmt) end def self.not_checked_in(code) where_stmt = "event_code__c = \'#{code}\' and status__c = \'processed\' and check_in_at__c = null" order_stmt = self.order_by(last_name__c: "ASC") - self.query(where_stmt, order_stmt) + self.query_with_reg_item_codes(where_stmt, order_stmt) end def self.not_checked_in_a_to_i(code) where_stmt = "event_code__c = \'#{code}\' and status__c = \'processed\' and check_in_at__c = null and last_name__c < \'J\'" order_stmt = self.order_by(last_name__c: "ASC") - self.query(where_stmt, order_stmt) + self.query_with_reg_item_codes(where_stmt, order_stmt) end def self.not_checked_in_j_to_r(code) where_stmt = "event_code__c = \'#{code}\' and status__c = \'processed\' and check_in_at__c = null and last_name__c > \'J\' and last_name__c < \'S\'" order_stmt = self.order_by(last_name__c: "ASC") - self.query(where_stmt, order_stmt) + self.query_with_reg_item_codes(where_stmt, order_stmt) end def self.not_checked_in_s_to_z(code) where_stmt = "event_code__c = \'#{code}\' and status__c = \'processed\' and check_in_at__c = null and last_name__c > \'S\'" order_stmt = self.order_by(last_name__c: "ASC") - self.query(where_stmt, order_stmt) + self.query_with_reg_item_codes(where_stmt, order_stmt) end def self.where(args = {}) @@ -172,6 +172,12 @@ def self.order_by(args = {}) "ORDER BY #{orders}" end + def self.query_with_reg_item_codes(where_stmt, order_stmt) + reg_item_select = "select code__c, reg_rate_code__c from reg_items__r" + sobjects = Sf.client.query("select Id, #{FIELDS_SELECT_STR}, (#{reg_item_select}) from RegRegistration__c where #{where_stmt} #{order_stmt}") + build_collection sobjects unless sobjects.blank? + end + def self.query(where_stmt, order_stmt) sobjects = Sf.client.query("select Id, #{FIELDS_SELECT_STR} from RegRegistration__c where #{where_stmt} #{order_stmt}") build_collection sobjects unless sobjects.blank? diff --git a/lib/sf/version.rb b/lib/sf/version.rb index c5ddceb..73ca367 100644 --- a/lib/sf/version.rb +++ b/lib/sf/version.rb @@ -1,3 +1,3 @@ module Sf - VERSION = "0.1.45" + VERSION = "0.1.46" end