<commit_before>import { Component, Input, OnChanges } from '@angular/core';
import { Task } from '../../models/task'
import { TickerItem } from '../../models/ticker'

@Component({
  selector: 'ticker-bar',
  templateUrl: 'ticker-bar.html'
})
export class TickerBarComponent implements OnChanges {

  @Input() task: Task
  @Input() items: TickerItem[] = []
  @Input() showAffirmation: boolean = false
  tickerItems: TickerItem[]
  tickerIndex: number = 0

  hasTask: boolean = true
  tickerWeeklyReport: string
  newWeeklyReport: boolean = false

  constructor() {
  }

  ngOnChanges (changes) {
    this.updateTickerItems()
    setInterval(() => {
      this.iterateIndex()
    }, 7500)
  }

  updateTickerItems () {
    this.tickerItems = []
    if(this.task['timestamp'] > 0){
      this.addTask()
    } else if(this.showAffirmation){
      this.addAffirmation()
    } else {
      this.addTasksNone()
    }
    this.tickerItems = this.tickerItems.concat(this.items)
    //TODO remove
    this.addAffirmation()
    this.addTasksNone()

    this.tickerItems.push(this.tickerItems[0])
  }

  showNextTickerItem () {
    let style = `translateX(-${this.tickerIndex * 100}%)`
    return style
  }

  iterateIndex () {
    this.tickerIndex += 1
    if(this.tickerIndex == (this.tickerItems.length)) {
      this.tickerIndex = 0
      this.updateTickerItems()
    }
    console.log(this.tickerIndex)
  }

  addTask () {
    let now = new Date()<commit_msg>Optimised ticker transform<commit_after>import { Component, Input, OnChanges } from '@angular/core';
import { Task } from '../../models/task'
import { TickerItem } from '../../models/ticker'

@Component({
  selector: 'ticker-bar',
  templateUrl: 'ticker-bar.html'
})
export class TickerBarComponent implements OnChanges {

  @Input() task: Task
  @Input() items: TickerItem[] = []
  @Input() showAffirmation: boolean = false
  tickerItems: TickerItem[]
  tickerIndex: number = 0

  hasTask: boolean = true
  tickerWeeklyReport: string
  newWeeklyReport: boolean = false

  constructor() {
  }

  ngOnChanges (changes) {
    this.updateTickerItems()
    
    if(this.tickerItems.length > 2){
      setInterval(() => {
        this.iterateIndex()
      }, 7500)
    }
  }

  updateTickerItems () {
    this.tickerItems = []
    if(this.task['timestamp'] > 0){
      this.addTask()
    } else if(this.showAffirmation){
      this.addAffirmation()
    } else {
      this.addTasksNone()
    }
    this.tickerItems = this.tickerItems.concat(this.items)
    this.tickerItems.push(this.tickerItems[0])
  }

  showNextTickerItem () {
    let style = `translateX(-${this.tickerIndex * 100}%)`
    return style
  }

  iterateIndex () {
    this.tickerIndex += 1
    if(this.tickerIndex == (this.tickerItems.length)) {
      this.tickerIndex = 0
      this.updateTickerItems()
    }
    console.log(this.tickerIndex)
  }

  addTask () {
    let now = new Date()
{'fraction_non_alphanumeric': 0.1416264645072364, 'fraction_numerical': 0.00861474844934528, 'mean_word_length': 3.06013986013986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '1444741', 'n_tokens_mistral': 1000, 'n_tokens_neox': 961, 'n_words': 183}