CSC/ECE 517 Fall 2019 - E1938. OSS project Duke Blue: Fix import glitches: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "Issue #918 New code introduced is as follows. File:app/helpers/import_topics_helper.rb Code: def self.define_attributes(row_hash) attributes = {} if !row_hash[:descriptio...")
 
No edit summary
Line 12: Line 12:
     attributes["topic_name"] = row_hash[:topic_name].strip
     attributes["topic_name"] = row_hash[:topic_name].strip
     attributes["max_choosers"] = row_hash[:max_choosers].strip
     attributes["max_choosers"] = row_hash[:max_choosers].strip
@@ -13,6 +17,13 @@ def self.define_attributes(row_hash)
     attributes
     attributes
   end
   end

Revision as of 19:42, 28 October 2019

Issue #918 New code introduced is as follows. File:app/helpers/import_topics_helper.rb Code: def self.define_attributes(row_hash)

   attributes = {}
   if !row_hash[:description].nil? and !row_hash[:description].ascii_only?
     row_hash[:description] = self.trim_non_ascii(row_hash[:description])
     puts row_hash[:description]
   end
   attributes["topic_identifier"] = row_hash[:topic_identifier].strip
   attributes["topic_name"] = row_hash[:topic_name].strip
   attributes["max_choosers"] = row_hash[:max_choosers].strip
   attributes
 end
 def self.trim_non_ascii(string)
   string.split().each do |char|
     !char.ascii_only? ? string.tr!(char, ' ') : nil
   end
   string.gsub!(/\s+/, ' ')
 end