Skip to content

Commit

Permalink
truncate long strings, ala http://bit.ly/IhJmWj
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Apr 29, 2012
1 parent 2f41e17 commit 3d86cdb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bigquery/transform.rb
Expand Up @@ -43,7 +43,14 @@ def flatmap(h, e, prefix = '')
if v.is_a?(Hash)
flatmap(h, v, prefix+k+"_")
else
h[prefix+k] = v unless v.is_a? Array
if not v.is_a? Array
if v.is_a? String
v = v.split.join(' ')
v = v[0,10000] + ' ...' if v.size > 10000
end

h[prefix+k] = v
end
end
end
h
Expand Down Expand Up @@ -85,7 +92,7 @@ def save(row, event, opt)
id, email, msg, name, flag = *commit
event['payload'].merge!({
'commit' => {
'id' => id, 'email' => email, 'msg' => msg.split.join(' '),
'id' => id, 'email' => email, 'msg' => msg,
'name' => name, 'flag' => flag
}
})
Expand All @@ -96,7 +103,7 @@ def save(row, event, opt)
pages = event['payload'].delete 'pages'

pages.each do |page|
page['summary'] = page['summary'].split.join(' ') if page['summary']
page['summary'] = page['summary'] if page['summary']
event['payload'].merge!({'page' => page})
save(r, event, options)
end
Expand Down

0 comments on commit 3d86cdb

Please sign in to comment.