<commit_before>import {Injectable} from '@angular/core';
import { Http, Response } from '@angular/http';
import {Todo} from './todo.model';
import { Observable } from 'rxjs/Rx';
import { Headers, RequestOptions } from '@angular/http';

@Injectable()
export class TodoService {
  constructor (private http: Http) {}
  private todoUrl = 'http://todo.kungfoobar.me/todo';
  getTodos (): Observable<Todo[]> {
    let headers = new Headers();
    headers.append('If-None-Match', '715347285830');
    return this.http.get(this.todoUrl, {headers})
                    .map(this.extractData)
                    .catch(this.handleError);
  }

  addTodo (note: string, priority: number, status: string) : Observable<Todo> {
    let body = JSON.stringify({ note, priority, status });
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    return this.http.post(this.todoUrl, body, options)
                    .map(this.extractData)
                    .catch(this.handleError);
  }

  private extractData(res: Response) {
    return res.json().map(function(todo){
        todo.created = new Date(todo.created).toDateString();
        return todo;
    })
    .sort(function(a, b) {
      return a.priority - b.priority;
});

  }
  private handleError (error: any) {
    let errMsg = error.message || error.statusText || 'Server error';
    console.error(errMsg); // log to console instead
    return Observable.throw(errMsg);
  }
}
<commit_msg>take 10 todos + file formatting<commit_after>import {Injectable} from '@angular/core';
import { Http, Response } from '@angular/http';
import {Todo} from './todo.model';
import { Observable } from 'rxjs/Rx';
import { Headers, RequestOptions } from '@angular/http';

@Injectable()
export class TodoService {
  constructor(private http: Http) { }
  private todoUrl = 'http://todo.kungfoobar.me/todo';
  getTodos(): Observable<Todo[]> {
    let headers = new Headers();
    headers.append('If-None-Match', '715347285830');
    return this.http.get(this.todoUrl, { headers })
      .map(this.extractData)
      .catch(this.handleError);
  }

  addTodo(note: string, priority: number, status: string): Observable<Todo> {
    let todo = { note, priority, status };
    let body = JSON.stringify(todo);
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    return this.http.post(this.todoUrl, body, options)
      .map(() => todo)
      .catch(this.handleError);
  }

  private extractData(res: Response) {
    return res.json().slice(20, 30)
      .map(function (todo) {
        todo.created = new Date(todo.created).toDateString();
        return todo;
      })
      .sort(function (a, b) {
        return a.priority - b.priority;
      });
  }
  private handleError(error: any) {
    let errMsg = error.message || error.statusText || 'Server error';
    console.error(errMsg); // log to console instead
    return Observable.throw(errMsg);
  }
}

{'fraction_non_alphanumeric': 0.14868421052631578, 'fraction_numerical': 0.009868421052631578, 'mean_word_length': 3.2002762430939224, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '5598955', 'n_tokens_mistral': 966, 'n_tokens_neox': 938, 'n_words': 228}