<commit_before>import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { Board, User, Note } from '../interfaces';

@Injectable({
  providedIn: 'root'
})
export class BoardApiService {
  private mockedUser: User = {
    key: 'userKey',
    nickname: 'googler',
    email: '<EMAIL>',
    accessibleBoards: []
  };
  private mockedNewBoardResponse: Board = {
    key: 'boardKey',
    notes: [],
    users: [],
    creationDate: this.currentTimestamp,
    title: 'boardTitle',
    creator: this.mockedUser,
    rows: 4,
    cols: 6,
    backgroundImg: null
  }

  constructor(private http: HttpClient) { }

  public getBoard(boardKey: string): Observable<Board> {
    const notes: Note[] = [];
    notes.push({
      key: 'key1',
      content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque porta odio ut magna finibus scelerisque vel malesuada mi.',
      image: null,
      creationDate: this.currentTimestamp,
      creator: '<EMAIL>',
      color: '#ffff99',
      boardKey: 'boardKey',
      x: 200,
      y: 0,
    });
    notes.push({
      key: 'key2',
      content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque porta odio ut magna finibus scelerisque vel malesuada mi.',
      image: null,
      creationDate: this.currentTimestamp,
      creator: '<EMAIL>',
      color: '#ccfff5',
      boardKey: 'boardKey',
      x: 400,
      y: 500,
    });
    notes.push({
      key: 'key3',
      content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque porta odio ut magna finibus scelerisque vel malesuada mi.',
      image: null,
      creationDate: this.currentTimestamp,
      creator: '<EMAIL>',
      color: '#ffe6ff',
      boardKey: 'boardKey',
      x: 600,
      y: 0,
    });
    notes.push({
      key: 'key4',
      content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque porta odio ut magna finibus scelerisque vel malesuada mi.',
      image: null,
      creationDate: this.currentTimestamp,
      creator: '<EMAIL>',
      color: '#e6e6ff',
      boardKey: 'boardKey',
      x: 600,
      y: 500,
    });

    const creator: User = {
      key: 'userKey',
      nickname: 'Googler',
      accessibleBoards: [],
      email: '<EMAIL>'
    };

    const board: Board = {
      key: boardKey,
      notes: notes,
      title: 'Board title',
      rows: 5,
      cols: 8,
      creator: creator,
      users: [],
      backgroundImg: null,
      creationDate: this.currentTimestamp,
    };

    creator.accessibleBoards.push(board);
    return of(board);
  }

  public createBoard(boardTitle: string): Observable<Board> {
    // return this.http.post<Board>('api/boards/', {title: boardTitle});
    return of(this.mockedNewBoardResponse);
  }

  public updateBoardTitle(boardKey: string, boardTitle: string): Observable<Board> {
    // return this.http.post<Board>(`api/boards/?id=${boardKey}`, {title: boardTitle});
    this.mockedNewBoardResponse.title = boardTitle;
    const mockedResponse = this.mockedNewBoardResponse;
    mockedResponse.title = boardTitle;
    return of(mockedResponse);
  }

  get currentTimestamp(): string {
    return Math.round(new Date().getTime()).toString()
  }
}<commit_msg>Update board service to use backend API<commit_after>import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { Board, User, Note } from '../interfaces';

@Injectable({
  providedIn: 'root'
})
export class BoardApiService {
  private mockedUser: User = {
    key: 'userKey',
    nickname: 'googler',
    email: '<EMAIL>',
    accessibleBoards: []
  };
  private mockedNewBoardResponse: Board = {
    key: 'boardKey',
    notes: [],
    users: [],
    creationDate: this.currentTimestamp,
    title: 'boardTitle',
    creator: this.mockedUser,
    rows: 4,
    cols: 6,
    backgroundImg: null
  }

  constructor(private http: HttpClient) { }

  public getBoard(boardId: string): Observable<Board> {
    return this.http.get<Board>(`api/board/?id=${boardId}`);
  }

  public createBoard(boardTitle: string): Observable<Board> {
    return this.http.post<Board>('api/board/', {title: boardTitle});
  }

  public updateBoardTitle(boardId: string, boardTitle: string): Observable<Board> {
    return this.http.patch<Board>(`api/boards/?id=${boardId}`, {title: boardTitle});
  }
}
{'fraction_non_alphanumeric': 0.13690610222922764, 'fraction_numerical': 0.008106282368835848, 'mean_word_length': 3.132093023255814, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3432833', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1422, 'n_words': 364}