Skip to content

Commit 37060d2

Browse files
authored
Merge pull request #251 from P3D-Legacy/develop
2 parents 8ed7efa + d2dbcfc commit 37060d2

62 files changed

Lines changed: 5479 additions & 1011 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DB_PASSWORD=
1616

1717
BROADCAST_DRIVER=log
1818
CACHE_DRIVER=file
19-
QUEUE_CONNECTION=sync
19+
QUEUE_CONNECTION=database
2020
SESSION_DRIVER=database
2121
SESSION_LIFETIME=120
2222

app/Console/Commands/SyncGameSave.php

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
namespace App\Console\Commands;
44

5+
use App\Jobs\SyncGameSaveForUser;
56
use App\Models\GamejoltAccount;
6-
use App\Models\GameSave;
7-
use Harrk\GameJoltApi\Exceptions\TimeOutException;
8-
use Harrk\GameJoltApi\GamejoltApi;
9-
use Harrk\GameJoltApi\GamejoltConfig;
107
use Illuminate\Console\Command;
11-
use Schema;
128

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

29-
private function handleGameSave($gamejolt_user_id, $api)
30-
{
31-
$gja = GamejoltAccount::firstWhere('id', $gamejolt_user_id);
32-
$new_game_save = new GameSave;
33-
$columns = Schema::getColumnListing($new_game_save->getTable());
34-
$result = [];
35-
try {
36-
foreach ($columns as $column) {
37-
if ($column == 'uuid' or $column == 'created_at' or $column == 'updated_at' or $column == 'user_id') {
38-
continue;
39-
}
40-
$key = 'saveStorageV1|'.$gamejolt_user_id.'|'.$column;
41-
$this->info('Getting "'.$key.'" from datastore');
42-
$ds_result = $api->dataStore()->fetch($key, $gja->username, $gja->token);
43-
$success = $ds_result['response']['success'];
44-
if (filter_var($success, FILTER_VALIDATE_BOOLEAN)) {
45-
$result[$column] = $ds_result['response']['data'];
46-
} else {
47-
$message = $ds_result['response']['message'];
48-
$this->error($message);
49-
break;
50-
}
51-
}
52-
} catch (TimeOutException $e) {
53-
$this->error('Error: '.$e->getMessage());
54-
55-
return Command::FAILURE;
56-
}
57-
$game_save = GameSave::where(['user_id' => $gja->user_id])->first();
58-
if ($game_save) {
59-
$game_save->update($result);
60-
} else {
61-
$result['user_id'] = $gja->user_id;
62-
GameSave::create($result);
63-
}
64-
}
65-
6625
/**
6726
* Execute the console command.
6827
*
@@ -77,7 +36,6 @@ public function handle()
7736

7837
return Command::FAILURE;
7938
}
80-
$api = new GamejoltApi(new GamejoltConfig($game_id, $private_key));
8139
$gamejolt_user_id = $this->argument('gamejolt_user_id');
8240
if ($gamejolt_user_id != 'all') {
8341
if (! is_numeric($gamejolt_user_id) || $gamejolt_user_id < 1) {
@@ -90,10 +48,11 @@ public function handle()
9048
if ($gamejolt_user_id == 'all') {
9149
$gamejolt_accounts = GamejoltAccount::all();
9250
foreach ($gamejolt_accounts as $gamejolt_account) {
93-
$this->handleGameSave($gamejolt_account->id, $api);
51+
SyncGameSaveForUser::dispatch($gamejolt_account->user);
9452
}
9553
} else {
96-
$this->handleGameSave($gamejolt_user_id, $api);
54+
$gamejolt_account = GamejoltAccount::firstWhere('gamejolt_user_id', $gamejolt_user_id);
55+
SyncGameSaveForUser::dispatch($gamejolt_account->user);
9756
}
9857

9958
$this->info('Done.');

app/Console/Commands/SyncGameSaveGamejoltAccountTrophies.php

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Jobs\SyncGameSaveGamejoltAccountTrophies;
6+
use App\Models\User;
7+
use Illuminate\Console\Command;
8+
9+
class SyncGameSaveTrophies extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'sync:gamesavetrophies {user_id=all}';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Sync trophies from the GameJolt API with the users game save';
24+
25+
/**
26+
* Execute the console command.
27+
*
28+
* @return int
29+
*/
30+
public function handle()
31+
{
32+
$argument = $this->argument('user_id');
33+
if ($argument != 'all') {
34+
if (! is_numeric($argument) || $argument < 1) {
35+
$this->error('User ID must be numeric');
36+
37+
return Command::FAILURE;
38+
}
39+
}
40+
41+
if ($argument == 'all') {
42+
$users = User::all();
43+
foreach ($users as $user) {
44+
SyncGameSaveGamejoltAccountTrophies::dispatch($user);
45+
}
46+
} else {
47+
$user = User::find($argument);
48+
if (! $user) {
49+
$this->error('User not found');
50+
51+
return Command::FAILURE;
52+
}
53+
SyncGameSaveGamejoltAccountTrophies::dispatch($user);
54+
}
55+
56+
return Command::SUCCESS;
57+
}
58+
}

app/Console/Commands/UpdateGamejoltAccountTrophies.php

Lines changed: 0 additions & 105 deletions
This file was deleted.

app/Http/Controllers/MemberController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MemberController extends Controller
1414
*/
1515
public function index(): View
1616
{
17-
$users = User::paginate(10);
17+
$users = User::verified()->paginate(10);
1818

1919
return view('member.index', ['users' => $users]);
2020
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Http\Livewire\Profile\GameSave;
4+
5+
use Livewire\Component;
6+
7+
class Details extends Component
8+
{
9+
public $gamesave;
10+
11+
public $details;
12+
13+
public function mount($gamesave)
14+
{
15+
$this->gamesave = $gamesave;
16+
$this->details = [];
17+
}
18+
19+
public function loadData()
20+
{
21+
$this->details = $this->gamesave->getPlayerDataDetails();
22+
}
23+
24+
public function render()
25+
{
26+
return view('livewire.profile.game-save.details');
27+
}
28+
}

0 commit comments

Comments
 (0)