wip
This commit is contained in:
1 parent
4b93848164
commit
20e93ba014
4 files changed
+62
-14
No files matched your search
+41
-6
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Pages;
|
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Pages;
|
||||||
|
|
||||||
use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlayerResource;
|
use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlayerResource;
|
||||||
use App\Filament\Exports\PlayerHistoryExporter;
|
use App\Filament\Exports\StatistikoPlayerExporter;
|
||||||
use App\Models\StatistikoPlayer;
|
use App\Models\StatistikoPlayer;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
@@ -12,6 +12,7 @@ use Filament\Actions\ExportAction;
|
|||||||
use Filament\Actions\Exports\Models\Export;
|
use Filament\Actions\Exports\Models\Export;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
class ListStatistikoPlayers extends ListRecords
|
class ListStatistikoPlayers extends ListRecords
|
||||||
{
|
{
|
||||||
@@ -21,12 +22,46 @@ class ListStatistikoPlayers extends ListRecords
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
ExportAction::make('download_players')
|
ExportAction::make('download_players')
|
||||||
->columnMapping(false)
|
|
||||||
->chunkSize(1000)
|
|
||||||
->exporter(PlayerHistoryExporter::class)
|
|
||||||
->label('Download')
|
->label('Download')
|
||||||
->fileName(fn (Export $export): string => 'player-history-'.date('d.m.Y-H.i')."-{$export->getKey()}")
|
->icon('phosphor-download')
|
||||||
->icon('phosphor-download'),
|
->columnMapping(false)
|
||||||
|
->chunkSize(500)
|
||||||
|
->exporter(StatistikoPlayerExporter::class)
|
||||||
|
->fileName(function (Export $export): string {
|
||||||
|
$options = $export->getOptions();
|
||||||
|
switch ($options['limit']) {
|
||||||
|
case 1:
|
||||||
|
return 'player-history-0-200k-'.date('d.m.Y-H.i');
|
||||||
|
case 2:
|
||||||
|
return 'player-history-200k-400k-'.date('d.m.Y-H.i');
|
||||||
|
case 3:
|
||||||
|
return 'player-history-400k-600k-'.date('d.m.Y-H.i');
|
||||||
|
case 4:
|
||||||
|
return 'player-history-600k-800k-'.date('d.m.Y-H.i');
|
||||||
|
case 5:
|
||||||
|
return 'player-history-800k-1000k-'.date('d.m.Y-H.i');
|
||||||
|
default:
|
||||||
|
return 'generic';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->modifyQueryUsing(function (Builder $query, array $options) {
|
||||||
|
if (isset($options['limit'])) {
|
||||||
|
switch ($options['limit']) {
|
||||||
|
case 1:
|
||||||
|
return $query->skip(0)->take(200000);
|
||||||
|
case 2:
|
||||||
|
return $query->skip(200000)->take(200000);
|
||||||
|
case 3:
|
||||||
|
return $query->skip(400000)->take(200000);
|
||||||
|
case 4:
|
||||||
|
return $query->skip(600000)->take(200000);
|
||||||
|
case 5:
|
||||||
|
return $query->skip(800000)->take(200000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}),
|
||||||
Action::make('count')
|
Action::make('count')
|
||||||
->color('gray')
|
->color('gray')
|
||||||
->tooltip('Count values from selected column')
|
->tooltip('Count values from selected column')
|
||||||
|
|||||||
+21
-3
@@ -2,15 +2,33 @@
|
|||||||
|
|
||||||
namespace App\Filament\Exports;
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
use App\Models\PlayerHistory;
|
use App\Models\StatistikoPlayer;
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
use Filament\Actions\Exports\Exporter;
|
use Filament\Actions\Exports\Exporter;
|
||||||
use Filament\Actions\Exports\Models\Export;
|
use Filament\Actions\Exports\Models\Export;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Illuminate\Support\Number;
|
use Illuminate\Support\Number;
|
||||||
|
|
||||||
class PlayerHistoryExporter extends Exporter
|
class StatistikoPlayerExporter extends Exporter
|
||||||
{
|
{
|
||||||
protected static ?string $model = PlayerHistory::class;
|
protected static ?string $model = StatistikoPlayer::class;
|
||||||
|
|
||||||
|
public static function getOptionsFormComponents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Select::make('limit')
|
||||||
|
->label('Pakets for export')
|
||||||
|
->options([
|
||||||
|
'1' => '0 - 200k',
|
||||||
|
'2' => '200k - 400k',
|
||||||
|
'3' => '400k - 600k',
|
||||||
|
'4' => '600k - 800k',
|
||||||
|
'5' => '800k - 1000k',
|
||||||
|
])
|
||||||
|
->default('all')
|
||||||
|
->required(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
@@ -70,13 +70,9 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
->color('success')
|
->color('success')
|
||||||
->action(function () {
|
->action(function () {
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
|
||||||
$events = Event::with(['odds_3ways', 'odds_totals', 'competition_group'])->where('starttime', '>', Carbon::now())->where('starttime', '<', Carbon::now()->addDays(15))->orderBy('starttime', 'ASC')->get();
|
$events = Event::with(['odds_3ways', 'odds_totals', 'competition_group'])->where('starttime', '>', Carbon::now())->where('starttime', '<', Carbon::now()->addDays(15))->orderBy('starttime', 'ASC')->get();
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
|
|
||||||
$event->loadMissing(['odds_3ways', 'odds_totals']);
|
$event->loadMissing(['odds_3ways', 'odds_totals']);
|
||||||
|
|
||||||
$totals = [];
|
$totals = [];
|
||||||
foreach ($event->odds_totals as $item) {
|
foreach ($event->odds_totals as $item) {
|
||||||
$bkmid = $item->bookmaker_id;
|
$bkmid = $item->bookmaker_id;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ return [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'connections' => [
|
'connections' => [
|
||||||
|
|
||||||
'sqlite' => [
|
'sqlite' => [
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'url' => env('DB_URL'),
|
'url' => env('DB_URL'),
|
||||||
|
|||||||
Reference in new issue
Block a user