lib/sportdb/models/track.rb in sportdb-1.6.11 vs lib/sportdb/models/track.rb in sportdb-1.6.12

- old
+ new

@@ -7,45 +7,15 @@ belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id' ##################### ## convenience helper for text parser/reader - ### fix: move to event!!! (e.g. scoped by event) - def self.known_tracks_table - - ## build known tracks table w/ synonyms e.g. - # - # [[ 'wolfsbrug', [ 'VfL Wolfsburg' ]], - # [ 'augsburg', [ 'FC Augsburg', 'Augi2', 'Augi3' ]], - # [ 'stuttgart', [ 'VfB Stuttgart' ]] ] - - known_tracks = [] - - Track.all.each_with_index do |track,index| + ### fix: move known_tracks_table to event!!! (e.g. scoped by event) - titles = [] - titles << track.title - titles += track.synonyms.split('|') if track.synonyms.present? - - ## NB: sort here by length (largest goes first - best match) - # exclude code and key (key should always go last) - titles = titles.sort { |left,right| right.length <=> left.length } - - ## escape for regex plus allow subs for special chars/accents - titles = titles.map { |title| TextUtils.title_esc_regex( title ) } - - known_tracks << [ track.key, titles ] - - ### fix: - ## plain logger - - LogUtils::Logger.root.debug " Track[#{index+1}] #{track.key} >#{titles.join('|')}<" - end - - known_tracks + def self.known_tracks_table + @@known_tracks_table ||= build_match_table_for( Track.all ) end # method known_tracks_table - def self.create_or_update_from_values( new_attributes, values ) ## fix: add/configure logger for ActiveRecord!!! \ No newline at end of file