<commit_before>package game.statistic;

import game.persistence.ScoreDao;
import jetbrains.buildServer.messages.Status;
import jetbrains.buildServer.serverSide.BuildServerAdapter;
import jetbrains.buildServer.serverSide.CustomDataStorage;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.serverSide.SRunningBuild;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.UserSet;
import jetbrains.buildServer.vcs.SelectPrevBuildPolicy;

/**
 * @author <NAME>
 */
public class BuildListener extends BuildServerAdapter {
    private ScoreDao scoreDao;

    public BuildListener(SBuildServer buildServer, ScoreDao scoreDao) {
        this.scoreDao = scoreDao;
        buildServer.addListener(this);
    }

    @Override
    public void buildFinished(SRunningBuild build) {
        if (build.getBuildStatus() == Status.NORMAL || build.getBuildStatus() == Status.WARNING) {
            addPointsToAllCommitters(build, 1);
        } else if (build.getBuildStatus() == Status.ERROR || build.getBuildStatus() == Status.FAILURE) {
            addPointsToAllCommitters(build, -5);
        }
    }

    private void addPointsToAllCommitters(SRunningBuild build, int points) {
        CustomDataStorage storage = build.getBuildType().getCustomDataStorage("ci-game");
        UserSet<SUser> committers = build.getCommitters(SelectPrevBuildPolicy.SINCE_LAST_BUILD);
        for (SUser committer : committers.getUsers()) {
            this.scoreDao.addScore(committer, points);
        }
    }
}
<commit_msg>personal builds can not be used to boost the score<commit_after>package game.statistic;

import game.persistence.ScoreDao;
import jetbrains.buildServer.messages.Status;
import jetbrains.buildServer.serverSide.BuildServerAdapter;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.serverSide.SRunningBuild;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.UserSet;
import jetbrains.buildServer.vcs.SelectPrevBuildPolicy;

/**
 * @author <NAME>
 */
public class BuildListener extends BuildServerAdapter {
    private ScoreDao scoreDao;

    public BuildListener(SBuildServer buildServer, ScoreDao scoreDao) {
        this.scoreDao = scoreDao;
        buildServer.addListener(this);
    }

    @Override
    public void buildFinished(SRunningBuild build) {
        if (build.isPersonal()) {
            return;
        }
        if (build.getBuildStatus() == Status.NORMAL || build.getBuildStatus() == Status.WARNING) {
            addPointsToAllCommitters(build, 1);
        } else if (build.getBuildStatus() == Status.ERROR || build.getBuildStatus() == Status.FAILURE) {
            addPointsToAllCommitters(build, -5);
        }
    }

    private void addPointsToAllCommitters(SRunningBuild build, int points) {
        UserSet<SUser> committers = build.getCommitters(SelectPrevBuildPolicy.SINCE_LAST_BUILD);
        for (SUser committer : committers.getUsers()) {
            this.scoreDao.addScore(committer, points);
        }
    }
}

{'fraction_non_alphanumeric': 0.09750492449113592, 'fraction_numerical': 0.0013131976362442547, 'mean_word_length': 3.914516129032258, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2406030', 'n_tokens_mistral': 870, 'n_tokens_neox': 875, 'n_words': 159}