<commit_before>// Copyright (c) 2016 <NAME>

import 'dart:async';
import 'dart:convert';

import 'package:http/http.dart' as http;

/// Stats of a given guardian.
class Guardian implements Comparable {
  final String destinyId;
  final String name;
  final int elo;
  final num kd;

  const Guardian(this.destinyId, this.name, this.elo, this.kd);

  @override
  int compareTo(Guardian other) => elo - other.elo;

  @override
  String toString() => '$name[$elo, $kd]';
}

/// Client for guardian.gg REST API.
class GuardianGgClient {
  /// Returns stats for the given player and their most recent fireteam members.
  Future<List<Guardian>> getTrialsStats(String destinyId) async {
    final url = 'https://api.guardian.gg/fireteam/14/$destinyId';
    final data = await _getJson(url);
    return data.map((Map guardian) {
      final destinyId = guardian['membershipId'];
      final name = guardian['name'];
      final elo = guardian['elo'].round();
      final kd = num
          .parse((guardian['kills'] / guardian['deaths']).toStringAsFixed(2));
      return new Guardian(destinyId, name, elo, kd);
    }).toList()..sort();
  }

  static dynamic _getJson(String url) async {
    return JSON.decode(await http.read(url));
  }
}<commit_msg>Handle the reset Trials stats better (#57)<commit_after>// Copyright (c) 2016 <NAME>

import 'dart:async';
import 'dart:convert';

import 'package:http/http.dart' as http;

/// Stats of a given guardian.
class Guardian implements Comparable {
  final String destinyId;
  final String name;
  final int elo;
  final num kd;

  const Guardian(this.destinyId, this.name, this.elo, this.kd);

  @override
  int compareTo(Guardian other) => elo - other.elo;

  @override
  String toString() => '$name[$elo, $kd]';
}

/// Client for guardian.gg REST API.
class GuardianGgClient {
  /// Returns stats for the given player and their most recent fireteam members.
  Future<List<Guardian>> getTrialsStats(String destinyId) async {
    final url = 'https://api.guardian.gg/fireteam/14/$destinyId';
    final data = await _getJson(url);
    return data.map((Map guardian) {
      final destinyId = guardian['membershipId'];
      final name = guardian['name'];
      final elo = guardian['elo'].round();
      final deaths = guardian['deaths'];
      final kd = num.parse(
          (deaths > 0 ? (guardian['kills'] / deaths) : 0).toStringAsFixed(2));
      return new Guardian(destinyId, name, elo, kd);
    }).toList()..sort();
  }

  static dynamic _getJson(String url) async {
    return JSON.decode(await http.read(url));
  }
}
{'fraction_non_alphanumeric': 0.1388997268825595, 'fraction_numerical': 0.00702301989855638, 'mean_word_length': 3.570409982174688, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6583606', 'n_tokens_mistral': 861, 'n_tokens_neox': 804, 'n_words': 236}