<commit_before>import { Component, OnInit, ViewChild, Type } from '@angular/core';
import { BarChartComponent, WidgetComponent } from '../index';
import { DataService } from '../../data/index';
import { UiRegistryService } from '../ui-registry.service';
import * as jsonpath from 'jsonpath';

@Component({
    moduleId: module.id,
    selector: 'as-widget-layout',
    templateUrl: 'widget-layout.html'
})
export class WidgetLayoutComponent implements OnInit {
    componentType: Type<any>;
    data: any;

    constructor(private dataService: DataService, private uiRegistryService: UiRegistryService) { }

    ngOnInit(): void {
        let sampleWidget = this.dataService.getSampleWidgetConfig();
        this.componentType = this.uiRegistryService.getComponentType(sampleWidget.type);

        this.dataService.executeAggregation(sampleWidget.connectionId, sampleWidget.collectionName, sampleWidget.query)
            .subscribe(result => {
                let barChartLabels: string[] = [];
                let barChartData: any[];

                let jobCountArray: any[] = [];
                if (result) {
                    // Need to parse this crap here
                    let res: any[] = result;
                    let resolve = jsonpath.query(res, '$[*].count');
                    console.log(resolve);
                    for (let entry of res) {
                        barChartLabels.push(new Date(entry._id.CreateDate.$date).toDateString());
                        jobCountArray.push(entry.count);
                    }
                }
                barChartData = [{ data: jobCountArray, label: 'Orders' }];
                this.data = { labels: barChartLabels, datasets: barChartData };
            },
            error => { console.log('error'); });
    }
}<commit_msg>parsing through jsonpath works, need converter libraries now<commit_after>import { Component, OnInit, ViewChild, Type } from '@angular/core';
import { BarChartComponent, WidgetComponent } from '../index';
import { DataService } from '../../data/index';
import { UiRegistryService } from '../ui-registry.service';
import * as jsonpath from 'jsonpath';

@Component({
    moduleId: module.id,
    selector: 'as-widget-layout',
    templateUrl: 'widget-layout.html'
})
export class WidgetLayoutComponent implements OnInit {
    componentType: Type<any>;
    data: any;

    constructor(private dataService: DataService, private uiRegistryService: UiRegistryService) { }

    ngOnInit(): void {
        let sampleWidget = this.dataService.getSampleWidgetConfig();
        this.componentType = this.uiRegistryService.getComponentType(sampleWidget.type);

        this.dataService.executeAggregation(sampleWidget.connectionId, sampleWidget.collectionName, sampleWidget.query)
            .subscribe(result => {
                let barChartLabels: string[] = [];
                let barChartData: any[];

                let jobCountArray: any[] = [];
                if (result) {
                    // Need to parse this crap here
                    let res: any[] = result;
                    jobCountArray = jsonpath.query(res, '$[*].count');
                    barChartLabels = jsonpath.query(res, '$[*]._id.CreateDate[\'$date\']');
                    console.log(jobCountArray);
                }
                barChartData = [{ data: jobCountArray, label: 'Orders' }];
                this.data = { labels: barChartLabels, datasets: barChartData };
            },
            error => { console.log('error'); });
    }
}
{'fraction_non_alphanumeric': 0.12248369719308194, 'fraction_numerical': 0.0, 'mean_word_length': 2.3064667291471417, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3520283', 'n_tokens_mistral': 915, 'n_tokens_neox': 883, 'n_words': 209}