dashboard/dashboard/spa/alerts-section.js
function handleBatch(results, showingTriaged) {
  const alerts = [];
  const nextRequests = [];
  const triagedRequests = [];
  let totalCount = 0;
  for (const {body, response} of results) {
    alerts.push.apply(alerts, response.anomalies);

    if (body.count_limit) totalCount += response.count;

    const cursor = response.next_cursor;
    if (cursor) {
      const request = {...body, cursor};
      delete request.count_limit;
      nextRequests.push(request);
    }

    if (!showingTriaged && body.bug_id === '') {
      // Prepare to fetch triaged alerts for the untriaged alerts that
      // were just received.
      const request = {...body, bug_id: '*'};
      delete request.recovered;
      delete request.count_limit;
      delete request.cursor;
      delete request.is_improvement;
      triagedRequests.push(request);
    }
  }

  return {alerts, nextRequests, triagedRequests, totalCount};
}
function handleBatch(results, showingTriaged) {
  const alerts = [];
  const nextRequests = [];
  const triagedRequests = [];
  let totalCount = 0;
  for (const {body, response} of results) {
    alerts.push.apply(alerts, response.anomalies);

    if (body.count_limit) totalCount += response.count;

    const cursor = response.next_cursor;
    if (cursor) {
      const request = {...body, cursor};
      delete request.count_limit;
      nextRequests.push(request);
    }

    if (!showingTriaged && body.bug_id === '') {
      // Prepare to fetch triaged alerts for the untriaged alerts that
      // were just received.
      const request = {...body, bug_id: '*'};
      delete request.recovered;
      delete request.count_limit;
      delete request.cursor;
      delete request.is_improvement;
      triagedRequests.push(request);
    }
  }

  return {alerts, nextRequests, triagedRequests, totalCount};
}
function handleBatch ( results , showingTriaged ) { const alerts = [ ] ; const nextRequests = [ ] ; const triagedRequests = [ ] ; let totalCount = 0 ; for ( const { body , response } of results ) { alerts . push . apply ( alerts , response . anomalies ) ; if ( body . count_limit ) totalCount += response . count ; const cursor = response . next_cursor ; if ( cursor ) { const request = { ... body , cursor } ; delete request . count_limit ; nextRequests . push ( request ) ; } if ( ! showingTriaged && body . bug_id === '' ) { // Prepare to fetch triaged alerts for the untriaged alerts that // were just received. const request = { ... body , bug_id : '*' } ; delete request . recovered ; delete request . count_limit ; delete request . cursor ; delete request . is_improvement ; triagedRequests . push ( request ) ; } } return { alerts , nextRequests , triagedRequests , totalCount } ; }
The BatchIterator in actions.loadAlerts yielded a batch of results. Collect all alerts from all batches into `alerts`. Chase cursors in `nextRequests`. Fetch triaged alerts when a request for untriaged alerts returns.
The BatchIterator in actions . loadAlerts yielded a batch of results . Collect all alerts from all batches into alerts . Chase cursors in nextRequests . Fetch triaged alerts when a request for untriaged alerts returns .