<commit_before>import { Component, Input, OnInit } from '@angular/core';
import { GeoDataService } from '../../services/geoservice';
import { Observable } from 'rxjs/Rx';
import { DivisionMetaDataModel } from '../../geodata/divisionmetadata.model';

import * as _ from 'lodash';
@Component({
    selector: 'division',
    templateUrl: './divisionmetadata.component.html'
})
export class DivisionMetaDataComponent {

    divisions: DivisionMetaDataModel[]

    constructor (private _geoservice : GeoDataService) {}

    ngOnInit() {
        this._geoservice.divisionMetaData.subscribe( ( divisions ) => {
            this.sortDivisions(divisions);
        });
    }

    sortDivisions(divisionData) {
        divisionData.sort(function(a, b) {
            a.name = _.capitalize(a.name);
            b.name = _.capitalize(b.name);
            return b.count - a.count;
        });
        this.divisions = divisionData;
    }
}<commit_msg>Changes made to the file to solve undefined count issue<commit_after>import { Component, Input, OnInit } from '@angular/core';
import { GeoDataService } from '../../services/geoservice';
import { Observable } from 'rxjs/Rx';
import { DivisionMetaDataModel } from '../../geodata/divisionmetadata.model';

import * as _ from 'lodash';
@Component({
    selector: 'division',
    templateUrl: './divisionmetadata.component.html'
})
export class DivisionMetaDataComponent {

    @Input() area

    divisions: DivisionMetaDataModel[]

    constructor (private _geoservice : GeoDataService) {}

    ngOnInit() {
        this._geoservice.divisionMetaData.subscribe( ( divisions ) => {
            this.sortDivisions(divisions);
        });
    }

    sortDivisions(divisionData) {
        divisionData.sort(function(a, b) {
            a.name = _.capitalize(a.name);
            b.name = _.capitalize(b.name);
            return _.get(b, 'count', 0) - _.get(a, 'count', 0);
        });

        let divisionItems = [];
        
        switch(this.area) {
            case 'geo-central-division' :
                divisionItems.push({
                    name: "Total Counts",
                    count: _.get(divisionData,'[0].count', 0)
                });
                break;
            case 'geo-ne-division' :
                divisionItems.push({
                    name: "Total Counts",
                    count: _.get(divisionData,'[1].count', 0)
                }); 
                break;
            case 'geo-west-division' :
                divisionItems.push({
                    name: "Total Counts",
                    count: _.get(divisionData,'[2].count', 0)
                }); 
                break;
            case 'kpi' :
                divisionItems = divisionData; 
                break;
        }

        this.divisions = divisionItems;
    }
}
{'fraction_non_alphanumeric': 0.1298932384341637, 'fraction_numerical': 0.0028469750889679717, 'mean_word_length': 1.949632738719832, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '138778', 'n_tokens_mistral': 802, 'n_tokens_neox': 748, 'n_words': 157}