<commit_before>import { Component } from '@angular/core'
import { NavController, NavParams } from 'ionic-angular'

import { UsageService } from '../../../core/services/usage/usage.service'
import { Assessment } from '../../../shared/models/assessment'
import { Task } from '../../../shared/models/task'
import { HomePageComponent } from '../../home/containers/home-page.component'
import { FinishTaskService } from '../services/finish-task.service'

@Component({
  selector: 'page-finish',
  templateUrl: 'finish-page.component.html'
})
export class FinishPageComponent {
  content = ''
  isClinicalTask = false
  completedInClinic = false
  displayNextTaskReminder = true
  showDoneButton = false
  task: Task
  questionnaireData
  assessment: Assessment

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private finish: FinishTaskService,
    private usage: UsageService
  ) {}

  ionViewDidLoad() {
    this.usage.setPage(this.constructor.name)
    this.init()
    this.onComplete().then(() => this.showDone())
  }

  init() {
    this.questionnaireData = this.navParams.data
    this.task = this.questionnaireData.task
    this.assessment = this.questionnaireData.assessment
    this.content = this.questionnaireData.endText
    this.isClinicalTask = this.task.isClinical !== false
    this.displayNextTaskReminder =
      !this.questionnaireData.isLastTask && !this.isClinicalTask
    setTimeout(() => (this.showDoneButton = true), 15000)
  }

  onComplete() {
    return Promise.all([
      this.finish.updateTaskToComplete(this.task),
      !this.task.name.includes('DEMO')
        ? this.finish.processDataAndSend(this.questionnaireData, this.task)
        : Promise.resolve()
    ])
  }

  showDone() {
    this.showDoneButton = true
  }

  handleClosePage() {
    const res = this.completedInClinic
      ? this.finish.evalClinicalFollowUpTask(this.assessment)
      : Promise.resolve()
    res.then(() => {
      this.showDoneButton = false
      return this.navCtrl.setRoot(HomePageComponent)<commit_msg>fix: Also send data if task name contains "DEMO"<commit_after>import { Component } from '@angular/core'
import { NavController, NavParams } from 'ionic-angular'

import { UsageService } from '../../../core/services/usage/usage.service'
import { Assessment } from '../../../shared/models/assessment'
import { Task } from '../../../shared/models/task'
import { HomePageComponent } from '../../home/containers/home-page.component'
import { FinishTaskService } from '../services/finish-task.service'

@Component({
  selector: 'page-finish',
  templateUrl: 'finish-page.component.html'
})
export class FinishPageComponent {
  content = ''
  isClinicalTask = false
  completedInClinic = false
  displayNextTaskReminder = true
  showDoneButton = false
  task: Task
  questionnaireData
  assessment: Assessment

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private finish: FinishTaskService,
    private usage: UsageService
  ) {}

  ionViewDidLoad() {
    this.usage.setPage(this.constructor.name)
    this.init()
    this.onComplete().then(() => this.showDone())
  }

  init() {
    this.questionnaireData = this.navParams.data
    this.task = this.questionnaireData.task
    this.assessment = this.questionnaireData.assessment
    this.content = this.questionnaireData.endText
    this.isClinicalTask = this.task.isClinical !== false
    this.displayNextTaskReminder =
      !this.questionnaireData.isLastTask && !this.isClinicalTask
    setTimeout(() => (this.showDoneButton = true), 15000)
  }

  onComplete() {
    return Promise.all([
      this.finish.updateTaskToComplete(this.task),
      this.finish.processDataAndSend(this.questionnaireData, this.task)
    ])
  }

  showDone() {
    this.showDoneButton = true
  }

  handleClosePage() {
    const res = this.completedInClinic
      ? this.finish.evalClinicalFollowUpTask(this.assessment)
      : Promise.resolve()
    res.then(() => {
      this.showDoneButton = false
      return this.navCtrl.setRoot(HomePageComponent)
{'fraction_non_alphanumeric': 0.12770137524557956, 'fraction_numerical': 0.002455795677799607, 'mean_word_length': 3.561030235162374, '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': '3518868', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1191, 'n_words': 225}