<commit_before>import { Component } from '@angular/core';

import {
  NavController,
  NavParams,
} from 'ionic-angular';

import {
  PollService
} from '../../providers/providers';

@Component({
  selector: 'page-poll',
  templateUrl: 'poll.html'
})
export class PollPage {
  room: String = this.navParams.get('room');
  poll: any;

  constructor(
    public ps: PollService,
    public navCtrl: NavController,
    public navParams: NavParams) { }

  ionViewDidLoad() {
    this.ps.poll(this.room).subscribe((poll) => {
      if (poll.data.length > 0 && poll.data[0].available) {
        this.poll = poll.data[0].questions[0] || poll.data[0].questions;
      } else {
        this.poll = null;
      }
    });
  }

  submit(answer) {
    this.ps.answer(this.poll, answer).subscribe((res) => console.info(res));
  }
}<commit_msg>refactor(poll): extract init poll to a function<commit_after>import { Component } from '@angular/core';

import {
  NavController,
  NavParams,
} from 'ionic-angular';

import {
  PollService
} from '../../providers/providers';

@Component({
  selector: 'page-poll',
  templateUrl: 'poll.html'
})
export class PollPage {
  room: String = this.navParams.get('room');
  poll: any;

  constructor(
    public ps: PollService,
    public navCtrl: NavController,
    public navParams: NavParams) { }

  ionViewDidLoad() {
    this.initPoll();
  }

  initPoll() {
    this.ps.poll(this.room).subscribe((poll) => {
      if (poll.data.length > 0 && poll.data[0].available) {
        this.poll = poll.data[0].questions[0] || poll.data[0].questions;
      } else {
        this.poll = null;
      }
    });
  }

  submit(answer) {
    this.ps.answer(this.poll, answer).subscribe((res) => console.info(res));
  }
}
{'fraction_non_alphanumeric': 0.16676283900750144, 'fraction_numerical': 0.005770340450086555, 'mean_word_length': 3.1187648456057007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3182465', 'n_tokens_mistral': 592, 'n_tokens_neox': 579, 'n_words': 112}