<commit_before>import 'dart:convert';
import 'dart:html';

import 'package:angular2/core.dart';

import 'package:simon/src/models/leader.dart';

@Injectable()
class LeaderboardService {
  List<Leader> leaders = [];
  
  LeaderboardService() {
    HttpRequest.getString('assets/leaderboard.json').then((String fileContents) {
      print(fileContents);
      List<Map> jsonLeaders = JSON.decode(fileContents);
      for (Map leader in jsonLeaders) {
        leaders.add(new Leader.fromMap(leader));
      }
    });
  }

  List<Map> getJSONLeaders() {
    List<Map> jsonLeaders = [];
    for (Leader leader in leaders) {
      jsonLeaders.add(leader.toMap());
    }
    
    return jsonLeaders;<commit_msg>handle if there are no leaders<commit_after>import 'dart:convert';
import 'dart:html';

import 'package:angular2/core.dart';

import 'package:simon/src/models/leader.dart';

@Injectable()
class LeaderboardService {
  List<Leader> leaders = [];
  
  LeaderboardService() {
    HttpRequest.getString('assets/leaderboard.json').then((String fileContents) {
      print(fileContents);
      if (fileContents.isNotEmpty) {
        List<Map> jsonLeaders = JSON.decode(fileContents);
        for (Map leader in jsonLeaders) {
          leaders.add(new Leader.fromMap(leader));
        }
      }
    });
  }

  List<Map> getJSONLeaders() {
    List<Map> jsonLeaders = [];
    for (Leader leader in leaders) {
      jsonLeaders.add(leader.toMap());
    }
    
    return jsonLeaders;
{'fraction_non_alphanumeric': 0.13599458728010824, 'fraction_numerical': 0.0013531799729364006, 'mean_word_length': 3.4682779456193353, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '3618432', 'n_tokens_mistral': 481, 'n_tokens_neox': 475, 'n_words': 84}