<commit_before>import {Response} from "@angular/http";

import {Observable} from "rxjs/Observable";


export class ResponseHandler {
    static extractData(res: Response) {
        let body;
        if (res.text()) {
            body = res.json();
        }
        return body || {};
    }

    static handleError(error: Response | any) {
        // TODO: rewrite
        let result: any;
        let text: string;
        if (error instanceof Response) {
            const body = error.json() || '';
            const err = body || JSON.stringify(body);
            text = `${error.status} - ${error.statusText || ''}`;
            result = err;
        } else {
            text = error.message ? error.message : error.toString();
            result = text;
        }
        console.error(text);
        return Observable.throw(result);
    }<commit_msg>HotFix for single model date<commit_after>import {Response} from "@angular/http";

import {Observable} from "rxjs/Observable";
import {Util} from "./utils";


export class ResponseHandler {
    static extractData(res: Response) {
        let body;
        if (res.text()) {
            body = res.json();
            body = ResponseHandler.processModel(body);
        }
        return body || {};
    }

    private static processModel(body: any) {
        let result = Util.copy(body);
        let date = body['importDate'];
        if (date) {
            result['importDate'] = new Date(date);
            console.log(date);
        }
        date = body['orderDate'];
        if (date) {
            result['orderDate'] = new Date(date);
        }
        return result;
    }

    static handleError(error: Response | any) {
        // TODO: rewrite
        let result: any;
        let text: string;
        if (error instanceof Response) {
            const body = error.json() || '';
            const err = body || JSON.stringify(body);
            text = `${error.status} - ${error.statusText || ''}`;
            result = err;
        } else {
            text = error.message ? error.message : error.toString();
            result = text;
        }
        console.error(text);
        return Observable.throw(result);
    }
{'fraction_non_alphanumeric': 0.1317228805834093, 'fraction_numerical': 0.0, 'mean_word_length': 1.7997448979591837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2882171', 'n_tokens_mistral': 590, 'n_tokens_neox': 585, 'n_words': 155}