<commit_before>import Ember from "ember";
import UserSettings from "../mixins/user-settings";

export default Ember.Controller.extend(UserSettings, {
    session: Ember.inject.service(),

    // Split results into waves
    // Important: waves must be loaded when processing this property
    results: Ember.computed("model.results", "waves", function() {
        if (!this.get("waves")) { return undefined; }
        if (!this.get("model.results")) { return undefined; }
        var res = [];

        this.get("model.results").forEach(function(item) {
            var wave_id = item.get("task.wave.id");
            if (!res[wave_id]) {
                res[wave_id] = Ember.Object.extend();
                res[wave_id].tasks = [item];
                res[wave_id].wave = item.get("task.wave");
                res[wave_id].max_score = item.get("task.max_score");
                res[wave_id].score = item.get("score");
                res[wave_id].sum_points = item.get("task.wave.sum_points");
            } else {
                res[wave_id].tasks.addObject(item);
                res[wave_id].max_score += item.get("task.max_score");
                res[wave_id].score += item.get("score");
            }
        });

        // calc percentages
        res.forEach(function(item) {
            item.percentage_submitted = ((item.score / item.max_score) * 100).toFixed(0);
            item.percentage_all = ((item.score / item.sum_points) * 100).toFixed(0);
        });

        return res;
    }),

    country: Ember.computed("model.addr_country", function() {
        var self = this;
        var arr = this.get("countries").filter(function(e) {
            return e.short === self.get("model.addr_country");
        });
        arr.push({ name: "" });<commit_msg>Show tasks with 0 points correctly in profile.<commit_after>import Ember from "ember";
import UserSettings from "../mixins/user-settings";

export default Ember.Controller.extend(UserSettings, {
    session: Ember.inject.service(),

    // Split results into waves
    // Important: waves must be loaded when processing this property
    results: Ember.computed("model.results", "waves", function() {
        if (!this.get("waves")) { return undefined; }
        if (!this.get("model.results")) { return undefined; }
        var res = [];

        this.get("model.results").forEach(function(item) {
            var wave_id = item.get("task.wave.id");
            if (!res[wave_id]) {
                res[wave_id] = Ember.Object.extend();
                res[wave_id].tasks = [item];
                res[wave_id].wave = item.get("task.wave");
                res[wave_id].max_score = item.get("task.max_score");
                res[wave_id].score = item.get("score");
                res[wave_id].sum_points = item.get("task.wave.sum_points");
            } else {
                res[wave_id].tasks.addObject(item);
                res[wave_id].max_score += item.get("task.max_score");
                res[wave_id].score += item.get("score");
            }
        });

        // calc percentages
        res.forEach(function(item) {
            if (item.max_score !== 0) {
                item.percentage_submitted = ((item.score / item.max_score) * 100).toFixed(0);
            } else {
                item.percentage_submitted = 100;
            }

            if (item.sum_points !== 0) {
                item.percentage_all = ((item.score / item.sum_points) * 100).toFixed(0);
            } else {
                item.percentage_all = 100;
            }
        });

        return res;
    }),

    country: Ember.computed("model.addr_country", function() {
        var self = this;
        var arr = this.get("countries").filter(function(e) {
            return e.short === self.get("model.addr_country");
        });
        arr.push({ name: "" });
{'fraction_non_alphanumeric': 0.1526219671275763, 'fraction_numerical': 0.006522306287503261, 'mean_word_length': 2.009419152276295, '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': '4707955', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1090, 'n_words': 201}