<commit_before>package models;

import com.avaje.ebean.Ebean;
import formatters.ScoreFormatter;
import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;

import static com.avaje.ebean.Expr.and;
import static com.avaje.ebean.Expr.eq;
import static java.text.MessageFormat.format;

@Entity
public class Score extends BaseModel<Score> implements Comparable<Score> {

    @XmlTransient
    @ManyToOne
    public Game game;

    @XmlTransient
    @ManyToOne
    public Player player;

    @XmlTransient
    @ManyToOne
    public Stage stage;

    @XmlTransient
    @ManyToOne
    public Mode mode;

    @XmlTransient
    @ManyToOne
    public Difficulty difficulty;

    @ManyToOne
    @XmlTransient
    public Platform platform;

    @Lob
    @XmlAttribute
    public String comment;

    @XmlAttribute
    public String photo;

    @XmlAttribute
    public String replay;

    public static Finder<Long, Score> finder = new Model.Finder(Long.class, Score.class);

    @Transient
    @XmlAttribute(name = "stage")
    public String stageName;

    @XmlAttribute
    public Long value;

    @Transient
    @XmlAttribute(name = "player")
    public String playerName;

    @XmlAttribute
    private Integer rank;

    public Score(Game game, Player player, Stage stage, Mode mode, Difficulty difficulty, String comment, Platform platform, Long value, String photo, String replay) {
        this.game = game;
        this.player = player;
        this.stage = stage;
        this.mode = mode;
        this.difficulty = difficulty;
        this.comment = comment;
        this.platform = platform;
        this.value = value;
        this.photo = photo;
        this.replay = replay;
    }

    public String formattedDate() {
        return getUpdatedSince();
    }

    public String formattedValue() {
        return ScoreFormatter.format(value);
    }

    public String formattedRank() {
        Integer value = rank();
        if(value == null) {
            value = 0;
        }
        int hundredRemainder = value % 100;
        int tenRemainder = value % 10;
        if (hundredRemainder - tenRemainder == 10) {
            return value + "th";
        }
        switch (tenRemainder) {
            case 1:
                return value + "st";
            case 2:
                return value + "nd";
            case 3:
                return value + "rd";
            default:
                return value + "th";
        }
    }

    public Integer rank() {
        return rank;
    }

    public boolean concerns(Difficulty difficulty) {
        return difficulty.equals(this.difficulty);
    }

    public boolean concerns(Mode mode) {
        return mode.equals(this.mode);
    }

    @Override
    public String toString() {
        return formattedValue();
    }

    @Override
    public int compareTo(Score score) {
        int i = score.value.compareTo(this.value);
        if (i == 0) {
            return score.stage.id.compareTo(this.stage.id);
        }
        return i;
    }

    @Override
    public boolean equals(Object o) {
        return value.equals(((Score) o).value);
    }

    public boolean isWorstThanOlders() {
        for (Score score : player.bestScores()) {
            if (score.isWorstThan(this)) {
                return true;
            }
        }
        return false;
    }

    boolean isWorstThan(Score score) {
        if (isComparableWith(score)) {<commit_msg>Cleaning<commit_after>package models;

import com.avaje.ebean.Ebean;
import formatters.ScoreFormatter;
import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;

import static com.avaje.ebean.Expr.and;
import static com.avaje.ebean.Expr.eq;
import static java.text.MessageFormat.format;

@Entity
public class Score extends BaseModel<Score> implements Comparable<Score> {

    @XmlTransient
    @ManyToOne
    public Game game;

    @XmlTransient
    @ManyToOne
    public Player player;

    @XmlTransient
    @ManyToOne
    public Stage stage;

    @XmlTransient
    @ManyToOne
    public Mode mode;

    @XmlTransient
    @ManyToOne
    public Difficulty difficulty;

    @ManyToOne
    @XmlTransient
    public Platform platform;

    @Lob
    @XmlAttribute
    public String comment;

    @XmlAttribute
    public String photo;

    @XmlAttribute
    public String replay;

    public static Finder<Long, Score> finder = new Model.Finder(Long.class, Score.class);

    @Transient
    @XmlAttribute(name = "stage")
    public String stageName;

    @XmlAttribute
    public Long value;

    @Transient
    @XmlAttribute(name = "player")
    public String playerName;

    @XmlAttribute
    private Integer rank;

    public Score(Game game, Player player, Stage stage, Mode mode, Difficulty difficulty, String comment, Platform platform, Long value, String photo, String replay) {
        this.game = game;
        this.player = player;
        this.stage = stage;
        this.mode = mode;
        this.difficulty = difficulty;
        this.comment = comment;
        this.platform = platform;
        this.value = value;
        this.photo = photo;
        this.replay = replay;
    }

    public String formattedDate() {
        return getUpdatedSince();
    }

    public String formattedValue() {
        return ScoreFormatter.format(value);
    }

    public String formattedRank() {
        Integer value = rank();
        if(value == null) {
            value = 0;
        }
        int hundredRemainder = value % 100;
        int tenRemainder = value % 10;
        if (hundredRemainder - tenRemainder == 10) {
            return value + "th";
        }
        switch (tenRemainder) {
            case 1:
                return value + "st";
            case 2:
                return value + "nd";
            case 3:
                return value + "rd";
            default:
                return value + "th";
        }
    }

    public Integer rank() {
        return rank;
    }

    @Override
    public String toString() {
        return formattedValue();
    }

    @Override
    public int compareTo(Score score) {
        int i = score.value.compareTo(this.value);
        if (i == 0) {
            return score.stage.id.compareTo(this.stage.id);
        }
        return i;
    }

    @Override
    public boolean equals(Object o) {
        return value.equals(((Score) o).value);
    }

    public boolean isWorstThanOlders() {
        for (Score score : player.bestScores()) {
            if (score.isWorstThan(this)) {
                return true;
            }
        }
        return false;
    }

    boolean isWorstThan(Score score) {
        if (isComparableWith(score)) {
{'fraction_non_alphanumeric': 0.0909479686386315, 'fraction_numerical': 0.003421240199572345, 'mean_word_length': 2.1560953666216824, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4400480', 'n_tokens_mistral': 2056, 'n_tokens_neox': 1960, 'n_words': 526}