<commit_before>import { GameTypes, GameType, Player, Achievement, PlayerGameInfo, PlayerInfo } from "hive-api"
import { LeaderboardUpdater } from "./LeaderboardUpdater"
import { UpdateService } from "./UpdateService";
import { database } from "firebase-admin";

export class AchievementUpdater extends LeaderboardUpdater {
    private static readonly GAME_TYPES_WITH_ACHIEVEMENTS: GameType[] = GameTypes.list.filter(type => type.playerGameInfoFactory.achievements !== undefined);
    protected _gamedataRef: database.Reference;

    get id() { return `leaderboard_achievements`; }

    constructor(db: database.Database) {
        super(db.ref("achievementLeaderboard"), "achievements", 100, 30*1000);

        this._gamedataRef = this._ref.child("gamedata");

        UpdateService.registerPlayerGameInfosUpdater(
            AchievementUpdater.GAME_TYPES_WITH_ACHIEVEMENTS,
            (info, player, playerInfos) => this.update(info, player, playerInfos),
            this.id
        );
    }

    private update(gameInfos: Map<GameType, PlayerGameInfo>, player: Player, playerInfo: PlayerInfo){
        let achievementCount: number = 0;        

        gameInfos.forEach((info: any, type: GameType) => {
            // after 1.1.2010 so we only get unlocked
            let gameTypeCount = 0;
<commit_msg>removed no longer used reference for gamedata<commit_after>import { GameTypes, GameType, Player, Achievement, PlayerGameInfo, PlayerInfo } from "hive-api"
import { LeaderboardUpdater } from "./LeaderboardUpdater"
import { UpdateService } from "./UpdateService";
import { database } from "firebase-admin";

export class AchievementUpdater extends LeaderboardUpdater {
    private static readonly GAME_TYPES_WITH_ACHIEVEMENTS: GameType[] = GameTypes.list.filter(type => type.playerGameInfoFactory.achievements !== undefined);

    get id() { return `leaderboard_achievements`; }

    constructor(db: database.Database) {
        super(db.ref("achievementLeaderboard"), "achievements", 100, 30*1000);

        UpdateService.registerPlayerGameInfosUpdater(
            AchievementUpdater.GAME_TYPES_WITH_ACHIEVEMENTS,
            (info, player, playerInfos) => this.update(info, player, playerInfos),
            this.id
        );
    }

    private update(gameInfos: Map<GameType, PlayerGameInfo>, player: Player, playerInfo: PlayerInfo){
        let achievementCount: number = 0;        

        gameInfos.forEach((info: any, type: GameType) => {
            // after 1.1.2010 so we only get unlocked
            let gameTypeCount = 0;

{'fraction_non_alphanumeric': 0.10290652003142184, 'fraction_numerical': 0.01335428122545169, 'mean_word_length': 3.681985294117647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2210856', 'n_tokens_mistral': 766, 'n_tokens_neox': 735, 'n_words': 169}