<commit_before>import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs';

import { HttpResponseHandler } from '../http-response-handler';
import { environment } from '../../../environments/environment';
import { Event } from './event.model';

@Injectable()
export class EventService extends HttpResponseHandler {
  public DAY_TIME = {
    AM: 1,
    PM: 2
  };

  private baseUrl: string = '/events';
  private url : string;

  constructor (
    private http: Http
  ) {
    super();

    this.url = `${environment.url}${this.baseUrl}`;
  }

  public getAll (): Observable<Event[]> {
    return this.http.get(this.url)
      .map(this.extractData)
      .catch(this.handleError);
  }

  public exists (day: string, dayTime: number): Observable<Boolean> {
    let time = '';

    switch (dayTime) {
      case this.DAY_TIME.AM:
        time = '09:00:00';
        break;

      case this.DAY_TIME.PM:
        time = '14:00:00';
        break;
    }

    return this.http.get(this.url, {
      search: `start=${day}T${time}`
    })
      .map(this.extractData)
      .map((events) => events.length >= 1)
      .catch(this.handleError);
  }

  public post (event: Event): Observable<Event> {
    return this.http.post(this.url, event)
      .map(this.extractData)
      .catch(this.handleError);
  }

}<commit_msg>chore(event): retrieve the selected day time enum<commit_after>import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs';

import { HttpResponseHandler } from '../http-response-handler';
import { environment } from '../../../environments/environment';
import { Event } from './event.model';

@Injectable()
export class EventService extends HttpResponseHandler {
  public DAY_TIME = {
    AM: 1,
    PM: 2
  };

  private baseUrl: string = '/events';
  private url : string;

  constructor (
    private http: Http
  ) {
    super();

    this.url = `${environment.url}${this.baseUrl}`;
  }

  public getAll (): Observable<Event[]> {
    return this.http.get(this.url)
      .map(this.extractData)
      .catch(this.handleError);
  }

  public exists (day: string, dayTime: number): Observable<Boolean> {
    let time = '';

    switch (dayTime) {
      case this.DAY_TIME.AM:
        time = '09:00:00';
        break;

      case this.DAY_TIME.PM:
        time = '14:00:00';
        break;
    }

    return this.http.get(this.url, {
      search: `start=${day}T${time}`
    })
      .map(this.extractData)
      .map((events) => events.length >= 1)
      .catch(this.handleError);
  }

  public post (event: Event): Observable<Event> {
    return this.http.post(this.url, event)
      .map(this.extractData)
      .catch(this.handleError);
  }

  public selectedDayTime (model: {am: Boolean, pm: Boolean}): number {
    if (model.am) {
      return this.DAY_TIME.AM;
    }

    if (model.pm) {
      return this.DAY_TIME.PM;
    }

    return 0;
  }

}
{'fraction_non_alphanumeric': 0.15604026845637584, 'fraction_numerical': 0.01040268456375839, 'mean_word_length': 2.6893564356435644, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '3208425', 'n_tokens_mistral': 998, 'n_tokens_neox': 964, 'n_words': 218}