<commit_before>import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs/Rx';

import { ConfigService, KillTimeToDatePipe } from '../shared';
import { KillmailService, Killmail } from '../z-killboard';
import { LoadKillsService } from './load-kills.service';

@Component({
  selector: 'app-kill-view',
  templateUrl: './kill-view.component.html',
  styleUrls: ['./kill-view.component.scss']
})
export class KillViewComponent implements OnInit, OnDestroy {
  logo = '';
  title = '';
  subtitle = '';
  background = '';
  backgroundIsDark = false;

  private sub: Subscription;
  year: number;
  month: number;

  private killIds: Observable<number[]>;
  killmails: Killmail[] = [];
  errorMessage: string = '';

  constructor(
    private route: ActivatedRoute,
    private configService: ConfigService,
    private killmailService: KillmailService,
    private loadKillsService: LoadKillsService
  ) { }

  ngOnInit() {
    this.configService.getHeroLogo().subscribe(logo => this.logo = logo);
    this.configService.getHeroTitle().subscribe(title => this.title = title);
    this.configService.getHeroSubtitle().subscribe(subtitle => this.subtitle = subtitle);
    this.configService.getHeroBackgroundImage().subscribe(image => this.background = image);
    this.configService.getHeroBackgroundIsDark().subscribe(bool => this.backgroundIsDark = bool);

    this.killIds = this.configService.getKillsUrl()
      .flatMap(url => this.loadKillsService.get(url));

    this.killIds
      .flatMap(ids => ids.reverse())
      .concatMap(id => this.killmailService.get(id))
      .subscribe(
      kill => {
        let list = this.killmails.concat(kill);
        list.sort((a, b) => Number(KillTimeToDatePipe.toDate(b.killTime)) - Number(KillTimeToDatePipe.toDate(a.killTime)));
        this.killmails = list;
      },
      error => this.errorMessage = 'There was a problem optaining kill information from zKillboard!'
      );

    this.sub = this.route.params.subscribe(params => {
      if (!params['year'] && !params['month']) {
        let today = new Date();
        this.year = today.getUTCFullYear();
        this.month = today.getUTCMonth() + 1;
      } else {
        this.year = Number(params['year']);
        this.month = Number(params['month']);
      }
    });
  }

  ngOnDestroy() {
    this.sub.unsubscribe();
  }
}<commit_msg>Adapted error message to the new behavior of loading one kill at a time<commit_after>import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs/Rx';

import { ConfigService, KillTimeToDatePipe } from '../shared';
import { KillmailService, Killmail } from '../z-killboard';
import { LoadKillsService } from './load-kills.service';

@Component({
  selector: 'app-kill-view',
  templateUrl: './kill-view.component.html',
  styleUrls: ['./kill-view.component.scss']
})
export class KillViewComponent implements OnInit, OnDestroy {
  logo = '';
  title = '';
  subtitle = '';
  background = '';
  backgroundIsDark = false;

  private sub: Subscription;
  year: number;
  month: number;

  private killIds: Observable<number[]>;
  killmails: Killmail[] = [];
  errorMessage: string = '';

  constructor(
    private route: ActivatedRoute,
    private configService: ConfigService,
    private killmailService: KillmailService,
    private loadKillsService: LoadKillsService
  ) { }

  ngOnInit() {
    this.configService.getHeroLogo().subscribe(logo => this.logo = logo);
    this.configService.getHeroTitle().subscribe(title => this.title = title);
    this.configService.getHeroSubtitle().subscribe(subtitle => this.subtitle = subtitle);
    this.configService.getHeroBackgroundImage().subscribe(image => this.background = image);
    this.configService.getHeroBackgroundIsDark().subscribe(bool => this.backgroundIsDark = bool);

    this.killIds = this.configService.getKillsUrl()
      .flatMap(url => this.loadKillsService.get(url));

    this.killIds
      .flatMap(ids => ids.reverse())
      .concatMap(id => this.killmailService.get(id))
      .subscribe(
      kill => {
        let list = this.killmails.concat(kill);
        list.sort((a, b) => Number(KillTimeToDatePipe.toDate(b.killTime)) - Number(KillTimeToDatePipe.toDate(a.killTime)));
        this.killmails = list;
      },
      error => this.errorMessage = 'Could not load all kills. There was a problem optaining kill information from zKillboard!'
      );

    this.sub = this.route.params.subscribe(params => {
      if (!params['year'] && !params['month']) {
        let today = new Date();
        this.year = today.getUTCFullYear();
        this.month = today.getUTCMonth() + 1;
      } else {
        this.year = Number(params['year']);
        this.month = Number(params['month']);
      }
    });
  }

  ngOnDestroy() {
    this.sub.unsubscribe();
  }
}
{'fraction_non_alphanumeric': 0.14466800804828975, 'fraction_numerical': 0.00040241448692152917, 'mean_word_length': 3.5773480662983426, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '238510', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1484, 'n_words': 304}