<commit_before>import axios from 'axios';
import { Observable, Observer } from 'rxjs';
import { PlayedMatch } from '../types/types';
import { BackendData } from '../types/backend-types';

export namespace WallService {

  let alreadyPlayedMatches: number = 0;
  const matchWall: Observable<Array<BackendData.Match>> = Observable
    .create((observer: Observer<Array<BackendData.Match>>) => {
      setInterval(
        () => {
          axios.get('/view/wall/matches')
            .then(res => (res.data as Array<BackendData.Match>))
            .then(matches => {
              if (matches.length > alreadyPlayedMatches) {
                observer.next(matches.slice(alreadyPlayedMatches));
                alreadyPlayedMatches = matches.length;
              }
            });
        },
        1000);
      observer.next([]);
    });

  export function playedMatches(): Observable<Array<PlayedMatch>> {
    return matchWall.map(matches => matches.map(match => ({
      team1: {
        player1: match.teamBlue.player1.value,
        player2: match.teamBlue.player2.value
      },
      team2: {
        player1: match.teamRed.player1.value,
        player2: match.teamRed.player2.value
      },
      winner: 'team1'
    }) as PlayedMatch));
  }
}
<commit_msg>Calculate winner team correctly in WallService<commit_after>import axios from 'axios';
import { Observable, Observer } from 'rxjs';
import { PlayedMatch } from '../types/types';
import { BackendData } from '../types/backend-types';

export namespace WallService {

  let alreadyPlayedMatches: number = 0;
  const matchWall: Observable<Array<BackendData.Match>> = Observable
    .create((observer: Observer<Array<BackendData.Match>>) => {
      setInterval(
        () => {
          axios.get('/view/wall/matches')
            .then(res => (res.data as Array<BackendData.Match>))
            .then(matches => {
              if (matches.length > alreadyPlayedMatches) {
                observer.next(matches.slice(alreadyPlayedMatches));
                alreadyPlayedMatches = matches.length;
              }
            });
        },
        1000);
      observer.next([]);
    });

  export function playedMatches(): Observable<Array<PlayedMatch>> {
    return matchWall.map(matches => 
      matches.map(match => {
        let wonSetsBlue = 0;
        let wonSetsRed = 0;

        match.matchSets.forEach(set => set.goalsBlue > set.goalsRed ? wonSetsBlue++ : wonSetsRed++);

        return {
          team1: {
            player1: match.teamBlue.player1.value,
            player2: match.teamBlue.player2.value
          },
          team2: {
            player1: match.teamRed.player1.value,
            player2: match.teamRed.player2.value
          },
          winner: wonSetsBlue > wonSetsRed ? 'team1' : 'team2'
        } as PlayedMatch;
      })
    );
  }
}

{'fraction_non_alphanumeric': 0.12976022566995768, 'fraction_numerical': 0.01234132581100141, 'mean_word_length': 2.260919540229885, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 34, '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': '3861284', 'n_tokens_mistral': 835, 'n_tokens_neox': 812, 'n_words': 152}