<commit_before>"use strict";

// TODO(Jonas): Rewrite this even more data driven: On input, change the data and redraw(), instead of chaning the HTML.

var timeFormat = d3.timeFormat("%Y-%m-%d %H:%M:%S");

function populatePlayerList(data) {
    var card =
        d3.select("#player_list")
            .selectAll("div.card")
            .data(data)
            .enter()
            .append("div")
            .attr("class", "card mb-2")
            .attr("id", function (d) {
                return "player_" + d["player_index"];
            })


    var card_body =
        card.append("div")
            .attr("class", "card-body")
            .style("display", "inline-flex");

    var left_part =
        card_body.append("div")
            .attr("class", "col-4");

    var header =
        left_part.append("h3")
            .attr("class", "card-title")
            .text(function (d) {
                return d["name"];
            });

    left_part.append("p")
        .attr("class", "card-text text-muted")
        .text(function (d) {
            return "Home team: " + d["origin"];
        });
    left_part.append("p")
        .attr("class", "card-text text-muted")
        .text(function (d) {
            return "Registered at " + d["time"];
        });

    var center_part =
        card_body.append("div")
            .attr("class", "col-4");

    var status_input_group = center_part.append("div")
        .attr("class", "input-group mb-3");

    status_input_group.append("div")
        .attr("class", "input-group-prepend")
        .append("label")
        .attr("class", "input-group-text")
        .attr("for", function (d) {
            return "selectPaymentStatus_" + d["player_index"];
        })
        .text("Payment status")

    var select = status_input_group.append("select")
        .attr("class", "custom-select")
        .attr("id", function (d) {
            return "selectPaymentStatus_" + d["player_index"];
        });

    select.append("option")
        .attr("value", "not paid")
        .text("Not paid")
        .property("selected", function (d) {
            return d.status === "not paid";
        });
    select.append("option")
        .attr("value", "paid")
        .text("Paid")
        .property("selected", function (d) {
            return d.status === "paid";
        });
    select.append("option")
        .attr("value", "no fee")
        .text("Disconnection (no fee)")
        .property("selected", function (d) {
            return d.status === "no fee";
        });
    select.append("option")
        .attr("value", "reimbursed")
        .text("Reimbursed")
        .property("selected", function (d) {
            return d.status === "reimbursed";
        });
    select.append("option")
        .attr("value", "other")
        .text("Other")
        .property("selected", function (d) {
            return d.status === "other";
        });

    select.on("change", function (player) {
        triggerPlayerUpdate(player);
    });

    center_part.append("div")
        .attr("class", "form-group")
        .append("textarea")
        .attr("class", "form-control")
        .attr("rows", 2)
        .attr("id", function (d) {
            return "notes_" + d["player_index"];
        })
        .text(function (d) {
            if (d["notes"]) {
                return d["notes"];
            }
        }).on("change", function (player) {
            triggerPlayerUpdate(player);
        });

    var right_part =
        card_body.append("div")
            .attr("class", "col-4");

    right_part.append("p")
        .attr("style", "display: none")
        .attr("id", function (d) {
            return "old_status_" + d["player_index"];
        })
        .text(function (d) {
            return d["status"];
        });

    right_part.append("p")
        .attr("class", "card-text text-muted")
        .attr("id", function (d) {
            return "change_info_" + d["player_index"];
        })
        .text(function (d) {
            if (d["last_author"]) {
                return "Last change: " + d["last_change"] + " (" + d["last_author"] + ")";
            }
        });

    right_part.append("p")
        .attr("class", "card-text text-muted")
        .attr("id", function (d) {
            return "confirmation_date_" + d["player_index"];
        })
        .text(function (d) {
            if (d["confirmation_date"]) {
                return "Payment confirmed: " + d["confirmation_date"];
            }
        });

    right_part.append("p")
        .attr("class", "card-text text-muted")
        .attr("id", function (d) {
            return "reimburse_date_" + d["player_index"];
        })
        .text(function (d) {
            if (d["reimburse_date"]) {
                return "Payment reimbursed: " + d["reimburse_date"];
            }
        });
};

function updateSummary(data) {
    // Create SVG placeholder.
    var svg = d3.select("div#summary")
        .append("svg")
        .attr("class", "col-md");

    // Aggregate data.
    var nested = d3.nest()
        .key(function (d) {
            return d["status"];
        })
        .rollup(function (v) {
            return v.length;<commit_msg>Fix bug where double login adds graphs instead of replacing the old<commit_after>"use strict";

// TODO(Jonas): Rewrite this even more data driven: On input, change the data and redraw(), instead of chaning the HTML.

var timeFormat = d3.timeFormat("%Y-%m-%d %H:%M:%S");

function populatePlayerList(data) {
    var card =
        d3.select("#player_list")
            .selectAll("div.card")
            .data(data)
            .enter()
            .append("div")
            .attr("class", "card mb-2")
            .attr("id", function (d) {
                return "player_" + d["player_index"];
            })


    var card_body =
        card.append("div")
            .attr("class", "card-body")
            .style("display", "inline-flex");

    var left_part =
        card_body.append("div")
            .attr("class", "col-4");

    var header =
        left_part.append("h3")
            .attr("class", "card-title")
            .text(function (d) {
                return d["name"];
            });

    left_part.append("p")
        .attr("class", "card-text text-muted")
        .text(function (d) {
            return "Home team: " + d["origin"];
        });
    left_part.append("p")
        .attr("class", "card-text text-muted")
        .text(function (d) {
            return "Registered at " + d["time"];
        });

    var center_part =
        card_body.append("div")
            .attr("class", "col-4");

    var status_input_group = center_part.append("div")
        .attr("class", "input-group mb-3");

    status_input_group.append("div")
        .attr("class", "input-group-prepend")
        .append("label")
        .attr("class", "input-group-text")
        .attr("for", function (d) {
            return "selectPaymentStatus_" + d["player_index"];
        })
        .text("Payment status")

    var select = status_input_group.append("select")
        .attr("class", "custom-select")
        .attr("id", function (d) {
            return "selectPaymentStatus_" + d["player_index"];
        });

    select.append("option")
        .attr("value", "not paid")
        .text("Not paid")
        .property("selected", function (d) {
            return d.status === "not paid";
        });
    select.append("option")
        .attr("value", "paid")
        .text("Paid")
        .property("selected", function (d) {
            return d.status === "paid";
        });
    select.append("option")
        .attr("value", "no fee")
        .text("Disconnection (no fee)")
        .property("selected", function (d) {
            return d.status === "no fee";
        });
    select.append("option")
        .attr("value", "reimbursed")
        .text("Reimbursed")
        .property("selected", function (d) {
            return d.status === "reimbursed";
        });
    select.append("option")
        .attr("value", "other")
        .text("Other")
        .property("selected", function (d) {
            return d.status === "other";
        });

    select.on("change", function (player) {
        triggerPlayerUpdate(player);
    });

    center_part.append("div")
        .attr("class", "form-group")
        .append("textarea")
        .attr("class", "form-control")
        .attr("rows", 2)
        .attr("id", function (d) {
            return "notes_" + d["player_index"];
        })
        .text(function (d) {
            if (d["notes"]) {
                return d["notes"];
            }
        }).on("change", function (player) {
            triggerPlayerUpdate(player);
        });

    var right_part =
        card_body.append("div")
            .attr("class", "col-4");

    right_part.append("p")
        .attr("style", "display: none")
        .attr("id", function (d) {
            return "old_status_" + d["player_index"];
        })
        .text(function (d) {
            return d["status"];
        });

    right_part.append("p")
        .attr("class", "card-text text-muted")
        .attr("id", function (d) {
            return "change_info_" + d["player_index"];
        })
        .text(function (d) {
            if (d["last_author"]) {
                return "Last change: " + d["last_change"] + " (" + d["last_author"] + ")";
            }
        });

    right_part.append("p")
        .attr("class", "card-text text-muted")
        .attr("id", function (d) {
            return "confirmation_date_" + d["player_index"];
        })
        .text(function (d) {
            if (d["confirmation_date"]) {
                return "Payment confirmed: " + d["confirmation_date"];
            }
        });

    right_part.append("p")
        .attr("class", "card-text text-muted")
        .attr("id", function (d) {
            return "reimburse_date_" + d["player_index"];
        })
        .text(function (d) {
            if (d["reimburse_date"]) {
                return "Payment reimbursed: " + d["reimburse_date"];
            }
        });
};

function updateSummary(data) {
    // Create SVG placeholder, delete old if there is one.
    var chart = d3.select("div#summary").select("svg");
    if (chart) {
        chart.remove();
    }
    var svg = d3.select("div#summary")
        .append("svg")
        .attr("class", "col-md");

    // Aggregate data.
    var nested = d3.nest()
        .key(function (d) {
            return d["status"];
        })
        .rollup(function (v) {
            return v.length;
{'fraction_non_alphanumeric': 0.17727745719421056, 'fraction_numerical': 0.0021757638823195536, 'mean_word_length': 1.7879746835443038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7264977', 'n_tokens_mistral': 3217, 'n_tokens_neox': 3123, 'n_words': 628}