Skip to content

Commit

Permalink
Merge pull request #251 from P3D-Legacy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbilling authored Feb 13, 2023
2 parents 8ed7efa + d2dbcfc commit 37060d2
Show file tree
Hide file tree
Showing 62 changed files with 5,479 additions and 1,011 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
QUEUE_CONNECTION=database
SESSION_DRIVER=database
SESSION_LIFETIME=120

Expand Down
49 changes: 4 additions & 45 deletions app/Console/Commands/SyncGameSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

namespace App\Console\Commands;

use App\Jobs\SyncGameSaveForUser;
use App\Models\GamejoltAccount;
use App\Models\GameSave;
use Harrk\GameJoltApi\Exceptions\TimeOutException;
use Harrk\GameJoltApi\GamejoltApi;
use Harrk\GameJoltApi\GamejoltConfig;
use Illuminate\Console\Command;
use Schema;

class SyncGameSave extends Command
{
Expand All @@ -26,43 +22,6 @@ class SyncGameSave extends Command
*/
protected $description = 'Sync a game save from the GameJolt API';

private function handleGameSave($gamejolt_user_id, $api)
{
$gja = GamejoltAccount::firstWhere('id', $gamejolt_user_id);
$new_game_save = new GameSave;
$columns = Schema::getColumnListing($new_game_save->getTable());
$result = [];
try {
foreach ($columns as $column) {
if ($column == 'uuid' or $column == 'created_at' or $column == 'updated_at' or $column == 'user_id') {
continue;
}
$key = 'saveStorageV1|'.$gamejolt_user_id.'|'.$column;
$this->info('Getting "'.$key.'" from datastore');
$ds_result = $api->dataStore()->fetch($key, $gja->username, $gja->token);
$success = $ds_result['response']['success'];
if (filter_var($success, FILTER_VALIDATE_BOOLEAN)) {
$result[$column] = $ds_result['response']['data'];
} else {
$message = $ds_result['response']['message'];
$this->error($message);
break;
}
}
} catch (TimeOutException $e) {
$this->error('Error: '.$e->getMessage());

return Command::FAILURE;
}
$game_save = GameSave::where(['user_id' => $gja->user_id])->first();
if ($game_save) {
$game_save->update($result);
} else {
$result['user_id'] = $gja->user_id;
GameSave::create($result);
}
}

/**
* Execute the console command.
*
Expand All @@ -77,7 +36,6 @@ public function handle()

return Command::FAILURE;
}
$api = new GamejoltApi(new GamejoltConfig($game_id, $private_key));
$gamejolt_user_id = $this->argument('gamejolt_user_id');
if ($gamejolt_user_id != 'all') {
if (! is_numeric($gamejolt_user_id) || $gamejolt_user_id < 1) {
Expand All @@ -90,10 +48,11 @@ public function handle()
if ($gamejolt_user_id == 'all') {
$gamejolt_accounts = GamejoltAccount::all();
foreach ($gamejolt_accounts as $gamejolt_account) {
$this->handleGameSave($gamejolt_account->id, $api);
SyncGameSaveForUser::dispatch($gamejolt_account->user);
}
} else {
$this->handleGameSave($gamejolt_user_id, $api);
$gamejolt_account = GamejoltAccount::firstWhere('gamejolt_user_id', $gamejolt_user_id);
SyncGameSaveForUser::dispatch($gamejolt_account->user);
}

$this->info('Done.');
Expand Down
86 changes: 0 additions & 86 deletions app/Console/Commands/SyncGameSaveGamejoltAccountTrophies.php

This file was deleted.

58 changes: 58 additions & 0 deletions app/Console/Commands/SyncGameSaveTrophies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Console\Commands;

use App\Jobs\SyncGameSaveGamejoltAccountTrophies;
use App\Models\User;
use Illuminate\Console\Command;

class SyncGameSaveTrophies extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync:gamesavetrophies {user_id=all}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Sync trophies from the GameJolt API with the users game save';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$argument = $this->argument('user_id');
if ($argument != 'all') {
if (! is_numeric($argument) || $argument < 1) {
$this->error('User ID must be numeric');

return Command::FAILURE;
}
}

if ($argument == 'all') {
$users = User::all();
foreach ($users as $user) {
SyncGameSaveGamejoltAccountTrophies::dispatch($user);
}
} else {
$user = User::find($argument);
if (! $user) {
$this->error('User not found');

return Command::FAILURE;
}
SyncGameSaveGamejoltAccountTrophies::dispatch($user);
}

return Command::SUCCESS;
}
}
105 changes: 0 additions & 105 deletions app/Console/Commands/UpdateGamejoltAccountTrophies.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Controllers/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MemberController extends Controller
*/
public function index(): View
{
$users = User::paginate(10);
$users = User::verified()->paginate(10);

return view('member.index', ['users' => $users]);
}
Expand Down
28 changes: 28 additions & 0 deletions app/Http/Livewire/Profile/GameSave/Details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Livewire\Profile\GameSave;

use Livewire\Component;

class Details extends Component
{
public $gamesave;

public $details;

public function mount($gamesave)
{
$this->gamesave = $gamesave;
$this->details = [];
}

public function loadData()
{
$this->details = $this->gamesave->getPlayerDataDetails();
}

public function render()
{
return view('livewire.profile.game-save.details');
}
}
Loading

0 comments on commit 37060d2

Please sign in to comment.