<commit_before>import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';

import {Task, Work} from '../models';
import { Data, Calculator, DateFormatter } from '../services';

@Component({
    selector: '<calendar-row>',
    inputs: ['task', 'startDate', 'endDate'],
    templateUrl: './template.html',
    styleUrls: ['./style.css']
})
export class CalendarRow implements OnInit {

    @Input() task: Task;
    @Input() startDate: Date;
    @Input() endDate: Date;
    work: number[] = [
        0,//u
        0,//m
        0,//t
        0,//w
        0,//r
        0,//f
        0,//s
    ];
    
    constructor(
        private data: Data,
        private calculator: Calculator,
        private dateFormatter: DateFormatter
    ) {
        
    }

    ngOnInit(): void {
        console.log('oninit')
        var q = {$and: [
                        { taskId: this.task._id },
                        { start: { $gte: this.startDate} },
                        { start: { $lte: this.endDate}}
                        ]}
        console.log('query', q)
        this.data.work.find(q, {start: 1})
            .then(work => {
                console.log('got work');
                work.forEach(workItem => {
                    var dayIndex = workItem.start.getDay();
                    var duration = workItem.duration;
                    console.log('Adding', duration, ' minues to', dayIndex);
                    this.work[workItem.start.getDay()] += workItem.duration;
                })
            }).catch(e => {
                console.error(e)
            }) 
    }
<commit_msg>move getting work to own function, leverage calculator service to get array of minuts worked, proper parent param bindings<commit_after>import { Component, OnInit, Input, EventEmitter, Output, OnChanges, SimpleChanges } from '@angular/core';

import {Task, Work} from '../models';
import { Data, Calculator, DateFormatter } from '../services';

@Component({
    selector: '<calendar-row>',
    inputs: ['task', 'centerDate'],
    templateUrl: './template.html',
    styleUrls: ['./style.css']
})
export class CalendarRow implements OnInit {

    @Input() task: Task;
    startDate: Date;
    endDate: Date;
    @Input() 
    set centerDate (dt: Date) {
        this.startDate = this.calculator.getMonday(dt);
        this.endDate = this.calculator.getSunday(dt);
        this.getWork();
    }

    work: number[] = [
        0,//u
        0,//m
        0,//t
        0,//w
        0,//r
        0,//f
        0,//s
    ];
    
    constructor(
        private data: Data,
        private calculator: Calculator,
        private dateFormatter: DateFormatter
    ) {
        
    }

    ngOnInit(): void {
        this.getWork();
    }

    getWork() {

        var q = {$and: [
                        { taskId: this.task._id },
                        { start: { $gte: this.startDate} },
                        { start: { $lte: this.endDate}}
                        ]}
        console.log('getWork', q)
        this.data.work.find(q, {start: 1})
            .then(work => {
                console.log('gotWork', work)
                this.work = this.calculator.weekOfWorkMinutes(work);
            }).catch(e => {
                console.error(e)
            }) 
    }

{'fraction_non_alphanumeric': 0.14442079659470963, 'fraction_numerical': 0.00486470051687443, 'mean_word_length': 1.5905511811023623, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '94353', 'n_tokens_mistral': 983, 'n_tokens_neox': 940, 'n_words': 218}