<commit_before>import { Injectable } from 'angular2/core';
import {Http, Headers, RequestOptions} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
import {GameOptions} from "./card";

@Injectable()
export class CardService {
    constructor(private http: Http) { }


    public getCards(gameOptions: GameOptions) {
        // we can change Zalando Shop based on the language
        let options = new RequestOptions({
            headers: new Headers({ 'Accept-Language': 'en-EN',
                'add' : 'zalmemo'
            })
        });
        // configure category and number of random items to retrieve
        let category = gameOptions.category;
        let numberOfItems = gameOptions.level.pairs;

        let resourceURL = 'https://api.zalando.com/articles?category=' + category + '&pageSize=1&page=';
        return this.http.get(resourceURL + 1, options)
            .map(res => { return res.json().totalPages })
            .map(totalPages => {
                let randomPageList: number[] = [];
                while (randomPageList.length < numberOfItems) {
                    var randomPageId = Math.floor(Math.random() * totalPages - 1) + 1;
                    if (randomPageList.indexOf(randomPageId) == -1) {
                        randomPageList.push(randomPageId);
                    }
                }
                return randomPageList;
            })
            .flatMap(pageList => {
                var list: Observable<any>[] = [];
                pageList.forEach(i=> list.push(this.http.get(resourceURL + i, options)))
                return Observable.forkJoin(list, function(...responses:any[]) {
                    var articleList: any[] = [];
                    responses.forEach(res => articleList.push(res.json().content[0]));

                    return {
                        content: articleList
                    }<commit_msg>#2 added x-client-name:zalmemo<commit_after>import { Injectable } from 'angular2/core';
import {Http, Headers, RequestOptions} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
import {GameOptions} from "./card";

@Injectable()
export class CardService {
    constructor(private http: Http) { }


    public getCards(gameOptions: GameOptions) {
        // we can change Zalando Shop based on the language
        let options = new RequestOptions({
            headers: new Headers({ 'Accept-Language': 'en-EN',
                'x-client-name' : 'zalmemo'
            })
        });
        // configure category and number of random items to retrieve
        let category = gameOptions.category;
        let numberOfItems = gameOptions.level.pairs;

        let resourceURL = 'https://api.zalando.com/articles?category=' + category + '&pageSize=1&page=';
        return this.http.get(resourceURL + 1, options)
            .map(res => { return res.json().totalPages })
            .map(totalPages => {
                let randomPageList: number[] = [];
                while (randomPageList.length < numberOfItems) {
                    var randomPageId = Math.floor(Math.random() * totalPages - 1) + 1;
                    if (randomPageList.indexOf(randomPageId) == -1) {
                        randomPageList.push(randomPageId);
                    }
                }
                return randomPageList;
            })
            .flatMap(pageList => {
                var list: Observable<any>[] = [];
                pageList.forEach(i=> list.push(this.http.get(resourceURL + i, options)))
                return Observable.forkJoin(list, function(...responses:any[]) {
                    var articleList: any[] = [];
                    responses.forEach(res => articleList.push(res.json().content[0]));

                    return {
                        content: articleList
                    }
{'fraction_non_alphanumeric': 0.11961347610342125, 'fraction_numerical': 0.004439801514755811, 'mean_word_length': 1.8475836431226766, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '4490947', 'n_tokens_mistral': 1027, 'n_tokens_neox': 977, 'n_words': 228}