Skip to content

Commit

Permalink
Add cursed comp IDs table
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirewraith committed Mar 8, 2024
1 parent c240dfc commit a5debbb
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Http/Controllers/Web/Admin/PlayersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Web\Admin;

use App\Http\Controllers\Controller;
use App\Models\CursedCompId;
use App\Models\GameRound;
use App\Models\Player;
use App\Traits\IndexableQuery;
Expand Down Expand Up @@ -69,6 +70,10 @@ public function show(Request $request, Player $player)
$ips = $player->connections->pluck('ip')->unique()->values();
$compIds = $player->connections->pluck('comp_id')->unique()->values();

// Remove any cursed computer IDs (those that are known to belong to shared/common computers)
$cursedCompIds = CursedCompId::all()->pluck('comp_id')->values();
$compIds = $compIds->diff($cursedCompIds);

$otherAccounts = Player::with(['latestConnection'])
->whereHas('connections', function ($query) use ($ips, $compIds) {
$query->whereIn('ip', $ips)
Expand Down
13 changes: 13 additions & 0 deletions app/Models/CursedCompId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CursedCompId extends Model
{
use HasFactory;

protected $table = 'cursed_comp_ids';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cursed_comp_ids', function (Blueprint $table) {
$table->id();
$table->text('comp_id');
$table->text('reason')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cursed_comp_ids');
}
};

0 comments on commit a5debbb

Please sign in to comment.