<commit_before>extends layout
include includes/mixins

block nav
    li
        a(href="/transactions") Transactions
    li
        a(href="/account-info") Account info
    li
        a(href="/configuration") Configuration
    li
        a(href="/logout") Logout

block content
    +kioskSelector(kiosks)
    div(style="width: 100%, height: 500px")#hourlyCash
    div(style="width: 100%, height: 500px")#dailyCash
    div(style="width: 100%, height: 500px")#monthlyCash

block footerJs
    script(src="https://www.google.com/jsapi")
    script.
        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawCharts);
        function drawCharts () {

            var dailyCashChart = new google.visualization.LineChart(document.getElementById('dailyCash'));
            var hourlyCashChart = new google.visualization.LineChart(document.getElementById('hourlyCash'));
            var monthlyCashChart = new google.visualization.LineChart(document.getElementById('monthlyCash'));

            var _fetchChartData = function () {

                var jsonData = $.ajax({
                    url: '/dashboard/summary',
                    data: {
                        kioskId: $('#kioskSelector').val()
                    },
                    dataType: 'json',
                    async: false,
                    success: function (data) {

                        var dailyCash = data.cashFlow.daily;
                        dailyCash.unshift(['Day', 'Cash In', 'Cash Out']);
                        var dailyCashData = google.visualization.arrayToDataTable(dailyCash);
                        dailyCashChart.draw(dailyCashData, {
                            title: 'Daily Cash In/Out',
                            vAxis: { title: '#{ kioskCurrency }' },
                            hAxis: { title: 'Day' },
                            animation: {
                                duration: 1000
                            }
                        });

                        var hourlyCash = data.cashFlow.hourly;
                        hourlyCash.unshift(['Hour', 'Cash In', 'Cash Out']);
                        var hourlyCashData = google.visualization.arrayToDataTable(hourlyCash);
                        hourlyCashChart.draw(hourlyCashData, {
                            title: 'Hourly Cash In/Out',
                            vAxis: { title: '#{ kioskCurrency }' },
                            hAxis: { title: 'Hour' },
                            animation: {
                                duration: 1000
                            }
                        });

                        var monthlyCash = data.cashFlow.monthly;
                        monthlyCash.unshift(['Month', 'Cash In', 'Cash Out']);
                        var monthlyCashData = google.visualization.arrayToDataTable(monthlyCash);
                        monthlyCashChart.draw(monthlyCashData, {
                            title: 'Monthly Cash In/Out',
                            vAxis: { title: '#{ kioskCurrency }' },
                            hAxis: { title: 'Month' },
                            animation: {
                                duration: 1000
                            }
                        });
                    }
                });
            };

            _fetchChartData();
            setInterval(_fetchChartData, 60000);<commit_msg>Hiding charting errors when no transactions<commit_after>extends layout
include includes/mixins

block nav
    li
        a(href="/transactions") Transactions
    li
        a(href="/account-info") Account info
    li
        a(href="/configuration") Configuration
    li
        a(href="/logout") Logout

block content
    +kioskSelector(kiosks)
    div(style="width: 100%, height: 500px")#hourlyCash
    div(style="width: 100%, height: 500px")#hourlyCashError
    div(style="width: 100%, height: 500px")#dailyCash
    div(style="width: 100%, height: 500px")#dailyCashError
    div(style="width: 100%, height: 500px")#monthlyCash
    div(style="width: 100%, height: 500px")#monthlyCashError

block footerJs
    script(src="https://www.google.com/jsapi")
    script.
        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawCharts);
        function drawCharts () {

            var dailyCashChart = new google.visualization.LineChart(document.getElementById('dailyCash'));
            var hourlyCashChart = new google.visualization.LineChart(document.getElementById('hourlyCash'));
            var monthlyCashChart = new google.visualization.LineChart(document.getElementById('monthlyCash'));

            var _fetchChartData = function () {

                var jsonData = $.ajax({
                    url: '/dashboard/summary',
                    data: {
                        kioskId: $('#kioskSelector').val()
                    },
                    dataType: 'json',
                    async: false,
                    success: function (data) {

                        var dailyCash = data.cashFlow.daily;
                        if (dailyCash.length > 0) {
                            dailyCash.unshift(['Day', 'Cash In', 'Cash Out']);
                            var dailyCashData = google.visualization.arrayToDataTable(dailyCash);
                            dailyCashChart.draw(dailyCashData, {
                                title: 'Daily Cash In/Out',
                                vAxis: { title: '#{ kioskCurrency }' },
                                hAxis: { title: 'Day' },
                                animation: {
                                    duration: 1000
                                }
                            });
                        } else {
                            $('#dailyCashError').text('You have no daily cash transaction summary');
                        }

                        var hourlyCash = data.cashFlow.hourly;
                        if (hourlyCash.length > 0) {
                            hourlyCash.unshift(['Hour', 'Cash In', 'Cash Out']);
                            var hourlyCashData = google.visualization.arrayToDataTable(hourlyCash);
                            hourlyCashChart.draw(hourlyCashData, {
                                title: 'Hourly Cash In/Out',
                                vAxis: { title: '#{ kioskCurrency }' },
                                hAxis: { title: 'Hour' },
                                animation: {
                                    duration: 1000
                                }
                            });
                        } else {
                            $('#hourlyCashError').text('You have no hourly cash transaction summary');
                        }

                        var monthlyCash = data.cashFlow.monthly;
                        if (monthlyCash.length > 0) {
                            monthlyCash.unshift(['Month', 'Cash In', 'Cash Out']);
                            var monthlyCashData = google.visualization.arrayToDataTable(monthlyCash);
                            monthlyCashChart.draw(monthlyCashData, {
                                title: 'Monthly Cash In/Out',
                                vAxis: { title: '#{ kioskCurrency }' },
                                hAxis: { title: 'Month' },
                                animation: {
                                    duration: 1000
                                }
                            });
                        } else {
                            $('#monthlyCashError').text('You have no monthly cash transaction summary');
                        }
                    }
                });
            };

            _fetchChartData();
            setInterval(_fetchChartData, 60000);
{'fraction_non_alphanumeric': 0.10226835832372165, 'fraction_numerical': 0.011918492887351018, 'mean_word_length': 1.2082625919637804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5738646', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1846, 'n_words': 355}