scripts/import.rb
# map GitHub JSON schema to flat CSV space based
# on provided Big Query column schema
map GitHub JSON schema to flat CSV space based
on provided Big Query column schema
map GitHub JSON schema to flat CSV space based on provided Big Query column schema
def flatmap(h, e, prefix = '')
  e.each do |k,v|
    if k == 'repo'
      k = 'repository'
    end
    if v.is_a?(Hash)
      flatmap(h, v, prefix+k+"_")
    else
      key = prefix+k
      next if !@keys.include? key
      case v
      when TrueClass then h[key] = 1
      when FalseClass then h[key] = 0
      else
        next if v.nil?
        h[key] = v unless v.is_a? Array
      end
    end
  end
  h
end
def flatmap ( h , e , prefix = '' ) e . each do | k , v | if k == 'repo' k = 'repository' end if v . is_a? ( Hash ) flatmap ( h , v , prefix + k + "_" ) else key = prefix + k next if ! @keys . include? key case v when TrueClass then h [ key ] = 1 when FalseClass then h [ key ] = 0 else next if v . nil? h [ key ] = v unless v . is_a? Array end end end h end
map GitHub JSON schema to flat CSV space based
on provided Big Query column schema
map GitHub JSON schema to flat CSV space based on provided Big Query column schema
h
<not_specific>
e
<not_specific>
prefix
<not_specific>