<commit_before><?php

use Illuminate\Database\Seeder;
use Faker\Factory as Faker;

class ScoreSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('osu_scores')->delete();
        DB::table('osu_scores_high')->delete();
        DB::table('osu_scores_taiko')->delete();
        DB::table('osu_scores_taiko_high')->delete();
        DB::table('osu_scores_fruits')->delete();
        DB::table('osu_scores_fruits_high')->delete();
        $beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get();
        $beatmapCount = count($beatmaps);
        $faker = Faker::create();

        if ($beatmapCount < 1) {
            $this->command->error('Unable to seed scores due to not having enough beatmap data.');

            return;
        }

        $users = App\Models\User::all();
        App\Models\Score\Model::unguard();

        $allBeatmapSets = App\Models\BeatmapSet::all();

        foreach ($users as $k => $u) {
            $osuBeatmaps = $beatmaps->where('playmode', 0)->take(20);
            $taikoBeatmaps = $beatmaps->where('playmode', 1)->take(20);
            $fruitsBeatmaps = $beatmaps->where('playmode', 2)->take(20);
            $maniaBeatmaps = $beatmaps->where('playmode', 3)->take(20);

        //add 20 osu! Standard scores
        foreach ($osuBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc = App\Models\Score\Osu::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
          ]);

            $sc2 = App\Models\Score\Best\Osu::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 1.5 * $bm->difficultyrating,
          ]);
        }

        //Taiko scores
        foreach ($taikoBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc3 = App\Models\Score\Taiko::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
          ]);

            $sc4 = App\Models\Score\Best\Taiko::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating,
          ]);
        } // end taiko

        //Fruits scores
        foreach ($fruitsBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc5 = App\Models\Score\Fruits::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
          ]);

            $sc6 = App\Models\Score\Best\Fruits::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating,
          ]);
        } // end fruits

        //Mania scores
        foreach ($maniaBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc7 = App\Models\Score\Mania::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
          ]);

            $sc8 = App\Models\Score\Best\Mania::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => rand(1, 1000),
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 2 * $bm->difficultyrating,
          ]);
        } // end mania
        }
        App\Models\Score\Model::reguard();
    }
}
<commit_msg>Add correct 'rank' value to score seeder<commit_after><?php

use Illuminate\Database\Seeder;
use Faker\Factory as Faker;

class ScoreSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('osu_scores')->delete();
        DB::table('osu_scores_high')->delete();
        DB::table('osu_scores_taiko')->delete();
        DB::table('osu_scores_taiko_high')->delete();
        DB::table('osu_scores_fruits')->delete();
        DB::table('osu_scores_fruits_high')->delete();
        $beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get();
        $beatmapCount = count($beatmaps);
        $faker = Faker::create();

        if ($beatmapCount < 1) {
            $this->command->error('Unable to seed scores due to not having enough beatmap data.');

            return;
        }

        $users = App\Models\User::all();
        App\Models\Score\Model::unguard();

        $allBeatmapSets = App\Models\BeatmapSet::all();

        $possible_ranks = ['A', 'S', 'B', 'SH', 'XH', 'X'];

        foreach ($users as $k => $u) {
            $osuBeatmaps = $beatmaps->where('playmode', 0)->take(20);
            $taikoBeatmaps = $beatmaps->where('playmode', 1)->take(20);
            $fruitsBeatmaps = $beatmaps->where('playmode', 2)->take(20);
            $maniaBeatmaps = $beatmaps->where('playmode', 3)->take(20);

        //add 20 osu! Standard scores
        foreach ($osuBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc = App\Models\Score\Osu::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
            'rank' => $possible_ranks[array_rand($possible_ranks)],
          ]);

            $sc2 = App\Models\Score\Best\Osu::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 1.5 * $bm->difficultyrating,
            'rank' => $possible_ranks[array_rand($possible_ranks)],
          ]);
        }

        //Taiko scores
        foreach ($taikoBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc3 = App\Models\Score\Taiko::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
            'rank' => $possible_ranks[array_rand($possible_ranks)],
          ]);

            $sc4 = App\Models\Score\Best\Taiko::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => $possible_ranks[array_rand($possible_ranks)],
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating,
          ]);
        } // end taiko

        //Fruits scores
        foreach ($fruitsBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc5 = App\Models\Score\Fruits::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => $possible_ranks[array_rand($possible_ranks)],
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
          ]);

            $sc6 = App\Models\Score\Best\Fruits::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => $possible_ranks[array_rand($possible_ranks)],
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 1.3 * $bm->difficultyrating,
          ]);
        } // end fruits

        //Mania scores
        foreach ($maniaBeatmaps as $bm) {
            $bms = $allBeatmapSets->find($bm->beatmapset_id);
            $maxcombo = rand(1, 5000);
            $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt
          $sc7 = App\Models\Score\Mania::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => $possible_ranks[array_rand($possible_ranks)],
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pass' => $faker->boolean(85), //85% chance of pass
          ]);

            $sc8 = App\Models\Score\Best\Mania::create([
            'user_id' => $u->user_id,
            'beatmap_id' => $bm->beatmap_id,
            'beatmapset_id' => $bm->beatmapset_id,
            'score' => rand(50000, 100000000),
            'maxcombo' => $maxcombo,
            'rank' => $possible_ranks[array_rand($possible_ranks)],
            'count300' => round($maxcombo * 0.8),
            'count100' => rand(0, round($maxcombo * 0.15)),
            'count50' => rand(0, round($maxcombo * 0.05)),
            'countgeki' => round($maxcombo * 0.3),
            'countmiss' => round($maxcombo * 0.05),
            'countkatu' => round($maxcombo * 0.05),
            'enabled_mods' => $possible_mods[array_rand($possible_mods)],
            'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now,
            'pp' => $faker->biasedNumberBetween(10, 100) * 2 * $bm->difficultyrating,
          ]);
        } // end mania
        }
        App\Models\Score\Model::reguard();
    }
}

{'fraction_non_alphanumeric': 0.18080082135523615, 'fraction_numerical': 0.062114989733059546, 'mean_word_length': 2.064977973568282, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 367, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 16, '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': '5820515', 'n_tokens_mistral': 7438, 'n_tokens_neox': 6508, 'n_words': 1171}