getLogStatistics method

  1. @override
Future<Map<String, int>> getLogStatistics()
override

Obtém estatísticas dos logs

Implementation

@override
Future<Map<String, int>> getLogStatistics() async {
  try {
    final allLogs = await _getAllLogs();

    return {
      'total': allLogs.length,
      'pending': allLogs.where((log) => !log.isSynced).length,
      'synced': allLogs.where((log) => log.isSynced).length,
      'failed':
          allLogs.where((log) => !log.isSynced && log.retryCount > 0).length,
      'files': allLogs.where((log) => log.isFileToUpload).length,
    };
  } catch (e) {
    developer.log(
      'Erro ao obter estatísticas dos logs: $e',
      name: 'InternalSyncLogStorage',
      level: 1000,
    );
    return {
      'total': 0,
      'pending': 0,
      'synced': 0,
      'failed': 0,
      'files': 0,
    };
  }
}