toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final t = now;
  return {
    'version': 1,
    'startedAt': startedAt.toIso8601String(),
    'updatedAt': t.toIso8601String(),
    'elapsedSeconds': t.difference(startedAt).inSeconds,
    'percent': double.parse(percent(t).toStringAsFixed(1)),
    'etaSeconds': eta(t).inSeconds,
    'parallel': parallel,
    'jobsTotal': jobs.length,
    'jobsDone': jobs.where((j) => j.isFinished).length,
    'jobsFailed': count(JobState.failed),
    'jobsRunning': count(JobState.running),
    'finished': jobs.every((j) => j.isFinished),
    'jobs': [
      for (final j in jobs)
        {
          'client': j.job.client,
          'platform': j.job.platform,
          'types': j.job.types,
          'state': j.state.name,
          'step': j.step,
          'targetsDone': j.targetsDone,
          'targetsTotal': j.job.targets.length,
          'percent': double.parse((100 * j.fraction(t)).toStringAsFixed(1)),
          'remainingSeconds': j.remaining(t).inSeconds,
          'elapsedSeconds': j.elapsed(t).inSeconds,
          if (j.logPath != null) 'log': j.logPath,
          if (j.detail != null) 'detail': j.detail,
        },
    ],
  };
}