<commit_before>import { Component } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';
import { DataService } from '../../../../core/api/data.service';
import { NzModalRef } from 'ng-zorro-antd';
import { Recipe } from '../../../../model/search/recipe';
import { GarlandToolsService } from '../../../../core/api/garland-tools.service';
import { HtmlToolsService } from '../../../../core/tools/html-tools.service';
import { debounceTime, filter, map, startWith, switchMap, tap } from 'rxjs/operators';

@Component({
  selector: 'app-recipe-choice-popup',
  templateUrl: './recipe-choice-popup.component.html',
  styleUrls: ['./recipe-choice-popup.component.less']
})
export class RecipeChoicePopupComponent {

  public query$: ReplaySubject<string> = new ReplaySubject<string>();

  public results$: Observable<Recipe[]>;

  loading = false;

  showCustom = false;

  warning: string;

  rotationId: string;

  constructor(private dataService: DataService, private dialogRef: NzModalRef,
              private gt: GarlandToolsService, private htmlTools: HtmlToolsService) {
    this.results$ = this.query$.pipe(
      debounceTime(500),
      filter(query => query.length > 3),
      tap(() => this.loading = true),
      switchMap(query => {
        return this.dataService.searchItem(query, [], true);
      }),
      map(results => {
        return results.map(res => res.recipe).filter(recipe => recipe !== undefined);
      }),
      tap(() => this.loading = false),
      startWith([])
    );
  }

  /**
   * Gets job informations from a given job id.
   * @param {number} id
   * @returns {any}
   */
  getJob(id: number): any {
    return this.gt.getJob(id);
  }<commit_msg>fix: fixed an issue with KO/ZH items search not available inside recipe picker<commit_after>import { Component } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';
import { DataService } from '../../../../core/api/data.service';
import { NzModalRef } from 'ng-zorro-antd';
import { Recipe } from '../../../../model/search/recipe';
import { GarlandToolsService } from '../../../../core/api/garland-tools.service';
import { HtmlToolsService } from '../../../../core/tools/html-tools.service';
import { debounceTime, filter, map, startWith, switchMap, tap } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core';

@Component({
  selector: 'app-recipe-choice-popup',
  templateUrl: './recipe-choice-popup.component.html',
  styleUrls: ['./recipe-choice-popup.component.less']
})
export class RecipeChoicePopupComponent {

  public query$: ReplaySubject<string> = new ReplaySubject<string>();

  public results$: Observable<Recipe[]>;

  loading = false;

  showCustom = false;

  warning: string;

  rotationId: string;

  constructor(private dataService: DataService, private dialogRef: NzModalRef,
              private gt: GarlandToolsService, private htmlTools: HtmlToolsService,
              private translate: TranslateService) {
    this.results$ = this.query$.pipe(
      debounceTime(500),
      filter(query => {
        if (['ko', 'zh'].indexOf(this.translate.currentLang.toLowerCase()) > -1) {
          // Chinese and korean characters system use fewer chars for the same thing, filters have to be handled accordingly.
          return query.length > 0;
        }
        return query.length > 3;
      }),
      tap(() => this.loading = true),
      switchMap(query => {
        return this.dataService.searchItem(query, [], true);
      }),
      map(results => {
        return results.map(res => res.recipe).filter(recipe => recipe !== undefined);
      }),
      tap(() => this.loading = false),
      startWith([])
    );
  }

  /**
   * Gets job informations from a given job id.
   * @param {number} id
   * @returns {any}
   */
  getJob(id: number): any {
    return this.gt.getJob(id);
  }
{'fraction_non_alphanumeric': 0.16156639004149378, 'fraction_numerical': 0.0025933609958506223, 'mean_word_length': 3.0988310308182783, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, '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': '3962188', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1133, 'n_words': 279}