Sha256: a2c28090a9220ad8dbb8d21c56ee1fa80db053d2fb78f840940e33fd0632a7e3

Contents?: true

Size: 673 Bytes

Versions: 16

Compression:

Stored size: 673 Bytes

Contents

class SchemaCommentMatcher
  KEY_DELIM = '_'.freeze

  def self.load_cache
    @cache = {}
    comments = SchemaComment.all
    comments.each do |comment|
      k = [comment.schema, comment.table, comment.column, comment.target_type].join(KEY_DELIM)
      @cache[k] = comment
    end
  end

  def self.enrich(columns)
    load_cache

    columns.each do |column|
      k = [column[:schema], column[:table], column[:column], column[:type]].join(KEY_DELIM)
      comment = @cache[k]

      if comment.present?
        column[:comment_text] = comment.text
        column[:comment_user_id] = comment.user_id
        column[:comment_id] = comment.id
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev lib/schema_comment_matcher.rb
aleph_analytics-0.4.8 lib/schema_comment_matcher.rb
aleph_analytics-0.4.7 lib/schema_comment_matcher.rb
aleph_analytics-0.4.4 lib/schema_comment_matcher.rb
aleph_analytics-0.4.2 lib/schema_comment_matcher.rb
aleph_analytics-0.4.1 lib/schema_comment_matcher.rb
aleph_analytics-0.3.0 lib/schema_comment_matcher.rb
aleph_analytics-0.2.0 lib/schema_comment_matcher.rb
aleph_analytics-0.1.0 lib/schema_comment_matcher.rb
aleph_analytics-0.0.6 lib/schema_comment_matcher.rb
aleph_analytics-0.0.5 lib/schema_comment_matcher.rb
aleph_analytics-0.0.4 lib/schema_comment_matcher.rb
aleph_analytics-0.0.3 lib/schema_comment_matcher.rb
aleph_analytics-0.0.2 lib/schema_comment_matcher.rb
aleph_analytics-0.0.1.alpha lib/schema_comment_matcher.rb
aleph_analytics-0.0.0.alpha lib/schema_comment_matcher.rb