| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 ///<reference path="../logdog-stream/logdog.ts" /> | 7 ///<reference path="../logdog-stream/logdog.ts" /> |
| 8 ///<reference path="../logdog-stream/client.ts" /> | 8 ///<reference path="../logdog-stream/client.ts" /> |
| 9 ///<reference path="../luci-operation/operation.ts" /> |
| 9 | 10 |
| 10 namespace LogDog { | 11 namespace LogDog { |
| 11 | 12 |
| 12 /** Returns true if "s" has glob characters in it. */ | 13 /** Returns true if "s" has glob characters in it. */ |
| 13 export function isQuery(s: string): boolean { | 14 export function isQuery(s: string): boolean { |
| 14 return (s.indexOf('*') >= 0); | 15 return (s.indexOf('*') >= 0); |
| 15 } | 16 } |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * Issues a query and iteratively pulls up to limit results. | 19 * Issues a query and iteratively pulls up to limit results. |
| 19 */ | 20 */ |
| 20 export async function | 21 export async function queryAll( |
| 21 queryAll(client: LogDog.Client, req: QueryRequest, limit: number): | 22 op: luci.Operation, client: LogDog.Client, req: QueryRequest, |
| 22 Promise<QueryResult[]> { | 23 limit: number): Promise<QueryResult[]> { |
| 23 let results: QueryResult[] = []; | 24 let results: QueryResult[] = []; |
| 24 let cursor = ''; | 25 let cursor = ''; |
| 25 | 26 |
| 26 for (let remaining = (limit || 100); remaining > 0;) { | 27 for (let remaining = (limit || 100); remaining > 0;) { |
| 27 console.log('Query', cursor, remaining); | 28 console.log('Query', cursor, remaining); |
| 28 let resp = await client.query(req, cursor, remaining); | 29 let resp = await client.query(op, req, cursor, remaining); |
| 29 if (!resp[0].length) { | 30 if (!resp[0].length) { |
| 30 break; | 31 break; |
| 31 } | 32 } |
| 32 | 33 |
| 33 results.push.apply(results, resp[0]); | 34 results.push.apply(results, resp[0]); |
| 34 remaining -= resp[0].length; | 35 remaining -= resp[0].length; |
| 35 | 36 |
| 36 cursor = resp[1]; | 37 cursor = resp[1]; |
| 37 if (!(cursor && cursor.length)) { | 38 if (!(cursor && cursor.length)) { |
| 38 break; | 39 break; |
| 39 } | 40 } |
| 40 } | 41 } |
| 41 | 42 |
| 42 return results; | 43 return results; |
| 43 } | 44 } |
| 44 } | 45 } |
| OLD | NEW |