big_query_log_viewer 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/big_query_log_viewer/components/tab.coffee +148 -108
- data/app/assets/javascripts/big_query_log_viewer/components/tab_manager.coffee +2 -2
- data/app/assets/javascripts/big_query_log_viewer/utils/query.coffee +3 -3
- data/lib/big_query_log_viewer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f22beb4892678ca9179a228569f982a43ca7a3a
|
4
|
+
data.tar.gz: f4d44663772b7cf8a52919f68549ad6ba18b1761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d8a613b0b9f2549a5584cd576a71a081b46fb84717dc83ecc8909be0bea28ead351dc1900837bc0ae567c3708aa590392a9541449ace4ed96164ea50e27d7e
|
7
|
+
data.tar.gz: 11d826779a401d3e3e5284a6f2632818324b9c0bf747bb55ec26774d225ae460c7e6bc5da822df0bd7207ff3a0c037b76228a1585f1d3032969ecdf3a656abe6
|
@@ -10,14 +10,24 @@ Row = BigQueryLogViewer.Row
|
|
10
10
|
|
11
11
|
BigQueryLogViewer.Tab = React.createClass
|
12
12
|
getInitialState: ->
|
13
|
+
pages = []
|
14
|
+
if @resultsTab()
|
15
|
+
rows = @props.tab.rowData
|
16
|
+
while rows.length >= @props.rowsPerPage
|
17
|
+
pages.push rows.splice(0, @props.rowsPerPage)
|
18
|
+
pages.push(rows) unless rows.length is 0
|
19
|
+
else
|
20
|
+
pages = [@props.tab.rowData]
|
13
21
|
{
|
14
|
-
pages:
|
22
|
+
pages: pages
|
15
23
|
activePageIndex: 0
|
16
24
|
pageToken: @props.tab.pageToken
|
17
25
|
showPrevLink: true
|
18
26
|
showNextLink: true
|
19
27
|
currentNextPage: 0
|
20
28
|
currentPrevPage: 0
|
29
|
+
storedNextRows: []
|
30
|
+
storedPrevRows: []
|
21
31
|
}
|
22
32
|
|
23
33
|
resultsTab: ->
|
@@ -41,7 +51,7 @@ BigQueryLogViewer.Tab = React.createClass
|
|
41
51
|
@setState(activePageIndex: @state.activePageIndex + 1)
|
42
52
|
else if @resultsTab()
|
43
53
|
# Else load next page from Google.
|
44
|
-
@props.query.executeListQuery({pageToken: @state.pageToken, jobId: @props.tab.jobId}, (response) =>
|
54
|
+
@props.query.executeListQuery({pageToken: @state.pageToken, jobId: @props.tab.jobId, maxResults: 1000}, (response) =>
|
45
55
|
rows =
|
46
56
|
for r in response.rows
|
47
57
|
{
|
@@ -52,7 +62,9 @@ BigQueryLogViewer.Tab = React.createClass
|
|
52
62
|
severity: r.f[2].v
|
53
63
|
msg: r.f[5].v
|
54
64
|
}
|
55
|
-
@
|
65
|
+
while rows.length >= @props.rowsPerPage
|
66
|
+
@state.pages.push(rows.splice(0, @props.rowsPerPage))
|
67
|
+
@state.pages.push rows unless rows.length is 0
|
56
68
|
@setState(
|
57
69
|
pageToken: response.pageToken
|
58
70
|
activePageIndex: @state.activePageIndex + 1
|
@@ -64,117 +76,145 @@ BigQueryLogViewer.Tab = React.createClass
|
|
64
76
|
alert 'Error loading more rows; check console for more information'
|
65
77
|
)
|
66
78
|
else if @expansionTab()
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
79
|
+
if @state.storedNextRows.length > 0
|
80
|
+
# If context already loaded, just concat the rows.
|
81
|
+
pages = @state.pages.slice()
|
82
|
+
pages[0] = pages[0].concat(@state.storedNextRows.splice(0, @props.rowsPerPage))
|
83
|
+
@setState(pages: pages)
|
84
|
+
else
|
85
|
+
# Load additional context.
|
86
|
+
startRow = @props.tab.row.rid + @props.rowsPerPage / 2 + 1 + @state.currentNextPage * 1000
|
87
|
+
endRow = @props.tab.row.rid + @props.rowsPerPage / 2 + 1 + (@state.currentNextPage + 1) * 1000
|
88
|
+
|
89
|
+
# Construct query.
|
90
|
+
conds = [
|
91
|
+
{
|
92
|
+
field: 'host'
|
93
|
+
method: 'equals'
|
94
|
+
type: 'string'
|
95
|
+
value: @props.tab.row.host
|
96
|
+
}
|
97
|
+
{
|
98
|
+
field: 'pid'
|
99
|
+
method: 'equals'
|
100
|
+
type: 'int'
|
101
|
+
value: @props.tab.row.pid
|
102
|
+
}
|
103
|
+
{
|
104
|
+
field: 'rid'
|
105
|
+
method: 'between'
|
106
|
+
firstValue: startRow
|
107
|
+
secondValue: endRow
|
108
|
+
}
|
109
|
+
]
|
110
|
+
query = @props.query.buildQuery(@props.tab.source.startDate, @props.tab.source.endDate, conds, 'ts, rid desc')
|
111
|
+
|
112
|
+
@props.query.executeQuery(query, {maxResults: 1000}, (response) =>
|
113
|
+
# Mark no more next if there were no results.
|
114
|
+
if parseInt(response.totalRows) == 0
|
115
|
+
@setState(showNextLink: false)
|
116
|
+
return
|
117
|
+
if parseInt(response.totalRows) < @props.rowsPerPage
|
118
|
+
@setState(showNextLink: false)
|
119
|
+
|
120
|
+
# Create new page for the expansion.
|
121
|
+
rows =
|
122
|
+
for r in response.rows
|
123
|
+
{
|
124
|
+
timestamp: new Date(1000 * r.f[0].v)
|
125
|
+
host: r.f[4].v
|
126
|
+
pid: r.f[3].v
|
127
|
+
rid: parseInt(r.f[1].v)
|
128
|
+
severity: r.f[2].v
|
129
|
+
msg: r.f[5].v
|
130
|
+
}
|
131
|
+
|
132
|
+
if rows.length > @props.rowsPerPage
|
133
|
+
@state.pages[0] = @state.pages[0].concat(rows.splice(0, @props.rowsPerPage))
|
134
|
+
@state.storedNextRows = rows
|
135
|
+
else
|
136
|
+
@state.pages[0] = @state.pages[0].concat(rows)
|
137
|
+
|
138
|
+
@setState(currentNextPage: @state.currentNextPage + 1)
|
139
|
+
|
140
|
+
, (reponse) =>
|
141
|
+
console.log "ERROR: #{response.message}; entire response follows"
|
142
|
+
console.log response
|
143
|
+
alert 'Error finding more context; check console for more information'
|
144
|
+
)
|
120
145
|
|
121
146
|
handlePrevPage: ->
|
122
147
|
if @resultsTab()
|
123
148
|
@setState(activePageIndex: @state.activePageIndex - 1)
|
124
149
|
else if @expansionTab()
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
conds = [
|
131
|
-
{
|
132
|
-
field: 'host'
|
133
|
-
method: 'equals'
|
134
|
-
type: 'string'
|
135
|
-
value: @props.tab.row.host
|
136
|
-
}
|
137
|
-
{
|
138
|
-
field: 'pid'
|
139
|
-
method: 'equals'
|
140
|
-
type: 'int'
|
141
|
-
value: @props.tab.row.pid
|
142
|
-
}
|
143
|
-
{
|
144
|
-
field: 'rid'
|
145
|
-
method: 'between'
|
146
|
-
firstValue: endRow
|
147
|
-
secondValue: startRow
|
148
|
-
}
|
149
|
-
]
|
150
|
-
query = @props.query.buildQuery(@props.tab.source.startDate, @props.tab.source.endDate, conds, 'ts, rid desc')
|
151
|
-
|
152
|
-
@props.query.executeQuery(query, {maxResults: @props.rowsPerPage}, (response) =>
|
153
|
-
# Mark no more prev if there were no results.
|
154
|
-
if parseInt(response.totalRows) == 0
|
155
|
-
@setState(showPrevLink: false)
|
156
|
-
return
|
157
|
-
|
158
|
-
# Create new page for the expansion.
|
159
|
-
rows =
|
160
|
-
for r in response.rows
|
161
|
-
{
|
162
|
-
timestamp: new Date(1000 * r.f[0].v)
|
163
|
-
host: r.f[4].v
|
164
|
-
pid: r.f[3].v
|
165
|
-
rid: parseInt(r.f[1].v)
|
166
|
-
severity: r.f[2].v
|
167
|
-
msg: r.f[5].v
|
168
|
-
}
|
150
|
+
if @state.storedPrevRows.length > 0
|
151
|
+
# If context already loaded, just concat the rows.
|
152
|
+
pages = @state.pages.slice()
|
153
|
+
pages[0] = @state.storedPrevRows.splice(-@props.rowsPerPage, @props.rowsPerPage).concat(pages[0])
|
154
|
+
@setState(pages: pages)
|
169
155
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
156
|
+
else
|
157
|
+
# Load additional context.
|
158
|
+
startRow = @props.tab.row.rid - @props.rowsPerPage / 2 - 1 - @state.currentPrevPage * 1000
|
159
|
+
endRow = @props.tab.row.rid - @props.rowsPerPage / 2 - 1 - (@state.currentPrevPage + 1) * 1000
|
160
|
+
|
161
|
+
# Construct query.
|
162
|
+
conds = [
|
163
|
+
{
|
164
|
+
field: 'host'
|
165
|
+
method: 'equals'
|
166
|
+
type: 'string'
|
167
|
+
value: @props.tab.row.host
|
168
|
+
}
|
169
|
+
{
|
170
|
+
field: 'pid'
|
171
|
+
method: 'equals'
|
172
|
+
type: 'int'
|
173
|
+
value: @props.tab.row.pid
|
174
|
+
}
|
175
|
+
{
|
176
|
+
field: 'rid'
|
177
|
+
method: 'between'
|
178
|
+
firstValue: endRow
|
179
|
+
secondValue: startRow
|
180
|
+
}
|
181
|
+
]
|
182
|
+
query = @props.query.buildQuery(@props.tab.source.startDate, @props.tab.source.endDate, conds, 'ts, rid desc')
|
183
|
+
|
184
|
+
@props.query.executeQuery(query, {maxResults: 1000}, (response) =>
|
185
|
+
# Mark no more prev if there were no results.
|
186
|
+
if parseInt(response.totalRows) == 0
|
187
|
+
@setState(showPrevLink: false)
|
188
|
+
return
|
189
|
+
if parseInt(response.totalRows) < @props.rowsPerPage
|
190
|
+
@setState(showPrevLink: false)
|
191
|
+
|
192
|
+
# Create new page for the expansion.
|
193
|
+
rows =
|
194
|
+
for r in response.rows
|
195
|
+
{
|
196
|
+
timestamp: new Date(1000 * r.f[0].v)
|
197
|
+
host: r.f[4].v
|
198
|
+
pid: r.f[3].v
|
199
|
+
rid: parseInt(r.f[1].v)
|
200
|
+
severity: r.f[2].v
|
201
|
+
msg: r.f[5].v
|
202
|
+
}
|
203
|
+
|
204
|
+
if rows.length > @props.rowsPerPage
|
205
|
+
@state.pages[0] = rows.splice(-@props.rowsPerPage, @props.rowsPerPage).concat(@state.pages[0])
|
206
|
+
@state.storedPrevRows = rows
|
207
|
+
else
|
208
|
+
@state.pages[0] = rows.concat(@state.pages[0])
|
209
|
+
|
210
|
+
@state.pages[0] = rows.concat(@state.pages[0])
|
211
|
+
@setState(currentPrevPage: @state.currentPrevPage + 1)
|
212
|
+
|
213
|
+
, (reponse) =>
|
214
|
+
console.log "ERROR: #{response.message}; entire response follows"
|
215
|
+
console.log response
|
216
|
+
alert 'Error finding more context; check console for more information'
|
217
|
+
)
|
178
218
|
|
179
219
|
handleShowPage: (event) ->
|
180
220
|
@setState(activePageIndex: parseInt(event.dispatchMarker.split('pagination-link-')[1]))
|
@@ -18,7 +18,7 @@ Query = BigQueryLogViewer.Query
|
|
18
18
|
|
19
19
|
BigQueryLogViewer.TabManager = React.createClass
|
20
20
|
getInitialState: ->
|
21
|
-
@query = new BigQueryLogViewer.Query(@props.projectId, @props.tablePrefix
|
21
|
+
@query = new BigQueryLogViewer.Query(@props.projectId, @props.tablePrefix)
|
22
22
|
|
23
23
|
{
|
24
24
|
tabs: []
|
@@ -135,7 +135,7 @@ BigQueryLogViewer.TabManager = React.createClass
|
|
135
135
|
]
|
136
136
|
query = @query.buildQuery(@activeTab().startDate, @activeTab().endDate, conds, 'ts, rid desc')
|
137
137
|
|
138
|
-
@query.executeQuery(query, {maxResults:
|
138
|
+
@query.executeQuery(query, {maxResults: @props.rowsPerPage * 2 + 1}, (response) =>
|
139
139
|
# Create new tab for the expansion.
|
140
140
|
rows =
|
141
141
|
for r in response.rows
|
@@ -1,7 +1,7 @@
|
|
1
1
|
window.BigQueryLogViewer ||= {}
|
2
2
|
|
3
3
|
class BigQueryLogViewer.Query
|
4
|
-
constructor: (@projectId, @tablePrefix
|
4
|
+
constructor: (@projectId, @tablePrefix) ->
|
5
5
|
#
|
6
6
|
|
7
7
|
tableRange: (startDate='CURRENT_TIMESTAMP()', endDate='CURRENT_TIMESTAMP()') ->
|
@@ -31,7 +31,7 @@ class BigQueryLogViewer.Query
|
|
31
31
|
|
32
32
|
executeQuery: (query, config, success, error) ->
|
33
33
|
console.log("Executing query: #{query}")
|
34
|
-
config.maxResults
|
34
|
+
config.maxResults ||= 1000
|
35
35
|
request = gapi.client.bigquery.jobs.query
|
36
36
|
projectId: @projectId
|
37
37
|
timeoutMs: 30000
|
@@ -46,7 +46,7 @@ class BigQueryLogViewer.Query
|
|
46
46
|
|
47
47
|
executeListQuery: (config, success, error) ->
|
48
48
|
console.log('Executing list query')
|
49
|
-
config.maxResults
|
49
|
+
config.maxResults ||= 1000
|
50
50
|
request = gapi.client.bigquery.jobs.getQueryResults
|
51
51
|
projectId: @projectId
|
52
52
|
jobId: config.jobId
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big_query_log_viewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Schneider
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|