<commit_before>/**
 * Created by kevin on 25/10/2015 for PodcastServer
 */
import _ from 'lodash';
import {RouteConfig, View, Module} from '../decorators';
import AppRouteConfig from '../config/route';
import StatsService from '../common/service/data/statsService';
import HighCharts from '../common/modules/highCharts';
import template from './stats.html!text';

@Module({
    name : 'ps.stats',
    modules : [
        AppRouteConfig,
        HighCharts,
        StatsService
    ]
})
@RouteConfig({
    path : '/stats',
    as : 'sc',
    resolve : {
        stats : statService => {"ngInject"; return statService.statsByType();}
    }
})
@View({
    template : template
})
export default class StatsController {

    constructor(statService, stats) {
        "ngInject";
        this.statService = statService;
        this.month = 1;

        this.chartSeries = [];
        this.transform(stats);
        this.chartConfig = statService.highChartsConfig(this.chartSeries);
    }

    transform(stats) {
        _.updateinplace(this.chartSeries, []);
        stats.map((value) => this.chartSeries.push({ name : value.type, data : this.statService.mapToHighCharts(value.values) }) );
    }

    navigate(offset) {
        this.month += offset;
        this.generateChartData();
    }

    generateChartData() {
        return this.statService
            .statsByType(this.month)
            .then(statsByType => this.transform(statsByType));
    }
}
<commit_msg>refactor(stats): simplify code and remove dependency to lodash<commit_after>/**
 * Created by kevin on 25/10/2015 for PodcastServer
 */
import {RouteConfig, View, Module} from '../decorators';
import AppRouteConfig from '../config/route';
import StatsService from '../common/service/data/statsService';
import HighCharts from '../common/modules/highCharts';
import template from './stats.html!text';

@Module({
    name : 'ps.stats',
    modules : [
        AppRouteConfig,
        HighCharts,
        StatsService
    ]
})
@RouteConfig({
    path : '/stats',
    as : 'sc',
    resolve : {
        stats : statService => {"ngInject"; return statService.statsByType();}
    }
})
@View({
    template : template
})
export default class StatsController {

    month = 1;

    constructor(statService, stats) {
        "ngInject";
        this.statService = statService;
        this.transform(stats);
    }

    transform(stats) {
        this.chartSeries = stats.map((value) => ({ name : value.type, data : this.statService.mapToHighCharts(value.values) }));
        this.chartConfig = this.statService.highChartsConfig(this.chartSeries);
    }

    navigate(offset) {
        this.month += offset;
        this.generateChartData();
    }

    generateChartData() {
        return this.statService
            .statsByType(this.month)
            .then(statsByType => this.transform(statsByType));
    }
}

{'fraction_non_alphanumeric': 0.1362369337979094, 'fraction_numerical': 0.0062717770034843206, 'mean_word_length': 2.748041775456919, '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': '2722574', 'n_tokens_mistral': 855, 'n_tokens_neox': 829, 'n_words': 176}