Class: IcfMasterTrackerUpdate
- Inherits:
-
ActiveRecordShared
- Object
- ActiveRecord::Base
- ActiveRecordShared
- IcfMasterTrackerUpdate
- Defined in:
- app/models/icf_master_tracker_update.rb
Instance Method Summary collapse
-
#parse ⇒ Object
This doesn’t really do much of anything yet.
Instance Method Details
#parse ⇒ Object
This doesn’t really do much of anything yet.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/icf_master_tracker_update.rb', line 10 def parse results = [] if !self.csv_file_file_name.blank? && File.exists?(self.csv_file.path) (f=FasterCSV.open( self.csv_file.path, 'rb',{ :headers => true })).each do |line| # "Masterid","Motherid","Record_Owner","Datereceived","Lastatt","Lastdisp","Currphone","Vacauthrecd","Recollect","Needpreincentive","Active_Phone","Recordsentformatching","Recordreceivedfrommatching","Sentpreincentive","Releasedtocati","Confirmedcaticontact","Refused","Deceasednotification","Eligible","Confirmationpacketsent","Catiprotocolexhausted","Newphonenumreleasedtocati","Pleanotificationsent","Casereturnedtoberkeleyfornewinf","Casereturnedfromberkeley","Caticomplete","Kitmothersent","Kitinfantsent","Kitchildsent","Kitadolescentsent","Kitmotherrefusedcode","Kitchildrefusedcode","Noresponsetoplea","Responsereceivedfromplea","Senttoinpersonfollowup","Kitmotherrecd","Kitchildrecvd","Thankyousent","Physrequestsent","Physresponsereceived" # # The IcfMasterTracker will include an after_save or something that will # determine what has changed and update appropriately. It may also # create OperationalEvents to document the data changes. As it is # theoretically possible that the Masterid does not exist in the identifiers # table, perhaps add a successfully_updated_models flag which could # be used? # icf_master_tracker = IcfMasterTracker.find_or_create_by_Masterid(line['Masterid']) # NO BANG. Don't want to raise any errors. successfully_updated = icf_master_tracker.update_attributes(line.to_hash) # # errors = icf_master_tracker.errors.full_messages.to_sentence # These won't be validation errors as there shouldn't be any. # Perhaps "no column by that name" errors if csv file changes? # # Add successfully_updated value? # icf_master_tracker.update_attribute(:sucessfully_updated, successfully_updated) # will the above include the line's attributes? # # Add update_errors column? # icf_master_tracker.update_attribute(:update_errors, errors) # results.push(icf_master_tracker) end # (f=FasterCSV.open( self.csv_file.path, 'rb',{ :headers => true })).each end # if !self.csv_file_file_name.blank? && File.exists?(self.csv_file.path) results # TODO why am I returning anything? will I use this later? end |