<commit_before>import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { League } from './../shared/league.model';
import { LeagueService } from './../shared/league.service';
import { Component, OnInit, Input } from '@angular/core';
import { environment } from '../../../environments/environment';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/switchMap';

@Component({
  selector: 'app-league-search',
  templateUrl: './league-search.component.html',
  styleUrls: ['./league-search.component.css']
})
export class LeagueSearchComponent implements OnInit {
  
  @Input() size: string = 'md';
  league: League;
  leagues: Observable<League[]>;

  constructor(
    private leagueService: LeagueService,
    private router: Router) { }

  ngOnInit() {
    this.league = new League();
  }

  goToLeague() {
    let url = ['/leagues', this.league.id];
    this.router.navigate(url);
    this.league = new League();
  }

  searchLeague = (text$: Observable<string>) =>
    text$
      .debounceTime(300)
      .distinctUntilChanged()
      .switchMap(term => this.leagueService.findByName(term));

  leagueFormatter(league: League): string {
    return league.name ? league.name : '';
  }

  leagueFound() {
    return this.league.name != null ? true : false;
  }
}<commit_msg>#115 Require the league search input to have at least 2 signs before searching<commit_after>import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { League } from './../shared/league.model';
import { LeagueService } from './../shared/league.service';
import { Component, OnInit, Input } from '@angular/core';
import { environment } from '../../../environments/environment';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/switchMap';
import 'rxjs/Rx';

@Component({
  selector: 'app-league-search',
  templateUrl: './league-search.component.html',
  styleUrls: ['./league-search.component.css']
})
export class LeagueSearchComponent implements OnInit {

  @Input() size: string = 'md';
  league: League;
  leagues: Observable<League[]>;

  constructor(
    private leagueService: LeagueService,
    private router: Router) { }

  ngOnInit() {
    this.league = new League();
  }

  goToLeague() {
    let url = ['/leagues', this.league.id];
    this.router.navigate(url);
    this.league = new League();
  }

  searchLeague = (text$: Observable<string>) =>
    text$
      .debounceTime(300)
      .distinctUntilChanged()
      .switchMap(term => term.length > 1
      ? this.leagueService.findByName(term)
      : Observable.of([]))

  leagueFormatter(league: League): string {
    return league.name ? league.name : '';
  }

  leagueFound() {
    return this.league.name != null ? true : false;
  }
}
{'fraction_non_alphanumeric': 0.15674740484429064, 'fraction_numerical': 0.0038062283737024223, 'mean_word_length': 3.7161500815660684, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '832267', 'n_tokens_mistral': 915, 'n_tokens_neox': 865, 'n_words': 202}