Skip to content
This repository
Browse code

truncate long strings, ala http://bit.ly/IhJmWj

  • Loading branch information...
commit 3d86cdb0c2c5bbcad963fa91a45b58a307e43b8b 1 parent 2f41e17
Ilya Grigorik authored

Showing 1 changed file with 10 additions and 3 deletions. Show diff stats Hide diff stats

  1. +10 3 bigquery/transform.rb
13 bigquery/transform.rb
@@ -43,7 +43,14 @@ def flatmap(h, e, prefix = '')
43 43 if v.is_a?(Hash)
44 44 flatmap(h, v, prefix+k+"_")
45 45 else
46   - h[prefix+k] = v unless v.is_a? Array
  46 + if not v.is_a? Array
  47 + if v.is_a? String
  48 + v = v.split.join(' ')
  49 + v = v[0,10000] + ' ...' if v.size > 10000
  50 + end
  51 +
  52 + h[prefix+k] = v
  53 + end
47 54 end
48 55 end
49 56 h
@@ -85,7 +92,7 @@ def save(row, event, opt)
85 92 id, email, msg, name, flag = *commit
86 93 event['payload'].merge!({
87 94 'commit' => {
88   - 'id' => id, 'email' => email, 'msg' => msg.split.join(' '),
  95 + 'id' => id, 'email' => email, 'msg' => msg,
89 96 'name' => name, 'flag' => flag
90 97 }
91 98 })
@@ -96,7 +103,7 @@ def save(row, event, opt)
96 103 pages = event['payload'].delete 'pages'
97 104
98 105 pages.each do |page|
99   - page['summary'] = page['summary'].split.join(' ') if page['summary']
  106 + page['summary'] = page['summary'] if page['summary']
100 107 event['payload'].merge!({'page' => page})
101 108 save(r, event, options)
102 109 end

0 comments on commit 3d86cdb

Please sign in to comment.
Something went wrong with that request. Please try again.