<commit_before>var app = angular.module('sg-timeline', [
    'ngRoute',
    'ngSanitize',
    'angular-timeline',
    'angular-scroll-animate',
    'chart.js'
]);

app.config(function ($routeProvider, $locationProvider, ChartJsProvider) {
    $routeProvider
        .when("/", {
            templateUrl: "timeline.html"
        })
        .otherwise("/", {
            templateUrl: "timeline.html"
        });

    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    });

    ChartJsProvider.setOptions('line', {
        showLines: false
    });
});

app.controller('AppController', function ($scope, $http) {
    $http.get("/config.json").then(function (response) {
        var remote = response.data.remote;

        var WEEK_COUNT = 15;

        $scope.events = [];

        $scope.badgeMap = {
            "active": "warning",
            "blacklisted": "danger",
            "beaten": "success",
            "played": "primary"
        };

        $scope.stats = {
            "blacklisted": 0,
            "beaten": 0,
            "active": 0,
            "played": 0 //for dummying
        };

        $http.get(remote + '/giveaways').then(function (response) {
            var giveaways = response.data;
            $http.get(remote + '/stats').then(function (response) {
                var stats = response.data;
                angular.forEach(giveaways, function (giveaway) {
                    giveaway.game.image = giveaway.game.image ? giveaway.game.image : "capsule_qm.png";
                    var event = {
                        badge: "primary",
                        game: giveaway.game,
                        when: moment(new Date(giveaway.winDate * 1000)).format("DD MMMM YYYY"),
                        creator: giveaway.creator,
                        types: giveaway.types,
                        level: giveaway.level,
                        stat: {
                            time: "0h 0m"
                        }
                    };

                    angular.forEach(Object.keys($scope.badgeMap), function (key) {
                        angular.forEach(stats[key], function (stat) {
                            if (giveaway.game.steamid == stat.steamid) {
                                $scope.stats[key]++;
                                event.badge = $scope.badgeMap[key];
                                var duration = moment.duration({
                                    minutes: stat.time
                                });
                                event.stat = {
                                    type: key,
                                    time: duration.isValid() ? (parseInt(duration.asHours()) + "h " + duration.minutes() + "m") : "N/A"
                                }
                            }
                        });
                    });

                    this.push(event);
                }, $scope.events);

            });
        });

        $scope.chartDummyData = [[null], [null], [null], [null]];
        $http.get(remote + '/statistics').then(function (response) {
            var data = response.data;

            $scope.chartLabels = [];
            for (var i = WEEK_COUNT; i > 0; i--) {
                $scope.chartLabels.push("Week " + (moment(new Date).isoWeek() - i));
            }

            var chartData = {};

            angular.forEach(data, function (week) {
                angular.forEach(Object.keys(week), function (stat) {
                    chartData[stat] ? chartData[stat].push(week[stat]) : chartData[stat] = [week[stat]];
                });
            });

            angular.forEach(chartData, function (dataSet) {
                var length = dataSet.length;
                for (var i = 0; i < WEEK_COUNT - length; i++) {
                    dataSet.unshift(null);
                }
            });

            $scope.chartDatasetOverride = [
                /* TODO: add won giveaway count
                 {
                 label: "Wins",
                 borderWidth: 6,
                 type: 'line',
                 pointBorderColor: "#00ff00",
                 borderColor: "#70ec69"
                 },*/
                {
                    label: "Beaten",
                    type: 'bar',
                    backgroundColor: "#3f903f",
                    hoverBackgroundColor: "#00ff00",
                    borderColor: "#fff",
                    stack: "Stack 0",<commit_msg>win ga count added to fe<commit_after>var app = angular.module('sg-timeline', [
    'ngRoute',
    'ngSanitize',
    'angular-timeline',
    'angular-scroll-animate',
    'chart.js'
]);

app.config(function ($routeProvider, $locationProvider, ChartJsProvider) {
    $routeProvider
        .when("/", {
            templateUrl: "timeline.html"
        })
        .otherwise("/", {
            templateUrl: "timeline.html"
        });

    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    });

    ChartJsProvider.setOptions('line', {
        showLines: false
    });
});

app.controller('AppController', function ($scope, $http) {
    $http.get("/config.json").then(function (response) {
        var remote = response.data.remote;

        var WEEK_COUNT = 15;

        $scope.events = [];

        $scope.badgeMap = {
            "active": "warning",
            "blacklisted": "danger",
            "beaten": "success",
            "played": "primary"
        };

        $scope.stats = {
            "blacklisted": 0,
            "beaten": 0,
            "active": 0,
            "played": 0 //for dummying
        };

        $http.get(remote + '/giveaways').then(function (response) {
            var giveaways = response.data;
            $http.get(remote + '/stats').then(function (response) {
                var stats = response.data;
                angular.forEach(giveaways, function (giveaway) {
                    giveaway.game.image = giveaway.game.image ? giveaway.game.image : "capsule_qm.png";
                    var event = {
                        badge: "primary",
                        game: giveaway.game,
                        when: moment(new Date(giveaway.winDate * 1000)).format("DD MMMM YYYY"),
                        creator: giveaway.creator,
                        types: giveaway.types,
                        level: giveaway.level,
                        stat: {
                            time: "0h 0m"
                        }
                    };

                    angular.forEach(Object.keys($scope.badgeMap), function (key) {
                        angular.forEach(stats[key], function (stat) {
                            if (giveaway.game.steamid == stat.steamid) {
                                $scope.stats[key]++;
                                event.badge = $scope.badgeMap[key];
                                var duration = moment.duration({
                                    minutes: stat.time
                                });
                                event.stat = {
                                    type: key,
                                    time: duration.isValid() ? (parseInt(duration.asHours()) + "h " + duration.minutes() + "m") : "N/A"
                                }
                            }
                        });
                    });

                    this.push(event);
                }, $scope.events);

            });
        });

        $scope.chartDummyData = [[null], [null], [null], [null], [null]];
        $http.get(remote + '/statistics').then(function (response) {
            var data = response.data;

            $scope.chartLabels = [];
            for (var i = WEEK_COUNT; i > 0; i--) {
                $scope.chartLabels.push("Week " + (moment(new Date).isoWeek() - i));
            }

            var chartData = {
                "blacklisted": [],
                "beaten": [],
                "active": [],
                "backlog": [],
                "win": []
            };
            for (var i = 1; i <= WEEK_COUNT; i++) {
                var week = moment(new Date).isoWeek() - i;

                angular.forEach(Object.keys(chartData), function (key) {
                    if (data[week] && data[week][key]) {
                        chartData[key].unshift(data[week][key])
                    } else {
                        chartData[key].unshift(0);
                    }
                });
            }

            $scope.chartDatasetOverride = [
                {
                    label: "Wins",
                    borderWidth: 0,
                    type: 'line',
                    pointBorderColor: "#000000",
                    borderColor: "#000000",
                    pointHoverBackgroundColor: "#ffffff",
                    data: chartData.win
                },
                {
                    label: "Beaten",
                    type: 'bar',
                    backgroundColor: "#3f903f",
                    hoverBackgroundColor: "#00ff00",
                    borderColor: "#fff",
                    stack: "Stack 0",
{'fraction_non_alphanumeric': 0.12854317732366513, 'fraction_numerical': 0.007800483410239508, 'mean_word_length': 1.1155008133860098, 'pattern_counts': {'":': 21, '<': 5, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '38228', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2238, 'n_words': 423}