(baseUrl, results, beforeId)
| 49 | |
| 50 | loadData () { |
| 51 | var fetchBatch = (baseUrl, results, beforeId) => { |
| 52 | let url = `${baseUrl}?options[limit]=${this.batchSize}` |
| 53 | if (beforeId) { url += `&options[beforeId]=${beforeId}` } |
| 54 | return new Promise(resolve => setTimeout(resolve.bind(null, Promise.resolve($.get(url))), 200)) |
| 55 | .then(batchResults => { |
| 56 | if (this.destroyed) { return Promise.resolve([]) } |
| 57 | results = results.concat(batchResults) |
| 58 | if (batchResults.length < this.batchSize) { |
| 59 | this.updateLoadingState(`Received ${results.length} from ${baseUrl} TOTAL`) |
| 60 | return Promise.resolve(results) |
| 61 | } else { |
| 62 | this.updateLoadingState(`Received ${results.length} from ${baseUrl} so far`) |
| 63 | return fetchBatch(baseUrl, results, batchResults[batchResults.length - 1]._id) |
| 64 | } |
| 65 | }).catch(error => { |
| 66 | console.log(new Date().toISOString(), `ERROR! Trying ${baseUrl} ${beforeId} again`, error.status, error.statusText) |
| 67 | return fetchBatch(baseUrl, results, beforeId) |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | return Promise.all([ |
| 72 | fetchBatch('/db/classroom/-/users', []), |
nothing calls this directly
no test coverage detected