grap zip mail
This commit is contained in:
1 parent
5081ec9e32
commit
dfed73b228
18 files changed
+484
-188
No files matched your search
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||
use App\Console\Commands\Grapper\Sofascore\Tools\LoadTournaments;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
@@ -15,21 +15,18 @@ class EventsDatabase
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$print = Nuh::$options['p'] ?? 0;
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
|
||||
$langsam = Nuh::$options['l'] ?? 0;
|
||||
|
||||
$days = SofaScoreDay::where('sport_id', $sport_id)->where('enabled', 1)->pluck('day')->toArray();
|
||||
$tornaments = SofaScoreTournament::where('sport_id', $sport_id)->where('enabled', 1)->get();
|
||||
|
||||
if (! $days) {
|
||||
Notice::note('No days active in DB', 'r', 1);
|
||||
}
|
||||
if (! $tornaments) {
|
||||
Notice::note('No tornaments active in DB', 'r', 1);
|
||||
}
|
||||
$days = LoadDays::load();
|
||||
|
||||
$tornaments = LoadTournaments::load();
|
||||
|
||||
if ($print) {
|
||||
dd($days, $tornaments);
|
||||
Notice::note($days, 'p');
|
||||
Notice::note($tornaments->toArray(), 'b', 1);
|
||||
}
|
||||
|
||||
foreach ($days as $day) {
|
||||
@@ -46,8 +43,7 @@ class EventsDatabase
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament->tournament_id/scheduled-events/$day";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
|
||||
$rand = self::rand($langsam);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
@@ -84,7 +80,7 @@ class EventsDatabase
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
$rand = self::rand($langsam);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
@@ -101,8 +97,8 @@ class EventsDatabase
|
||||
*********************************/
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
|
||||
$rand = self::rand($langsam);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
@@ -120,7 +116,7 @@ class EventsDatabase
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
$rand = self::rand($langsam);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
@@ -136,4 +132,14 @@ class EventsDatabase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function rand(bool $langsam = false)
|
||||
{
|
||||
if($langsam){
|
||||
return rand(500000, 50000000);
|
||||
}
|
||||
else {
|
||||
return rand(500000, 1000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
class Helper
|
||||
{
|
||||
public static function map() {}
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Specials\CountPlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\Specials\CreateZip;
|
||||
use App\Console\Commands\Grapper\Sofascore\Specials\LeaguesToLocal;
|
||||
use App\Console\Commands\Grapper\Sofascore\Specials\PlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\Specials\SendMail;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
@@ -11,22 +14,47 @@ ini_set('magic_quotes_runtime', false);
|
||||
class Special
|
||||
{
|
||||
|
||||
public static string $source_path;
|
||||
|
||||
public static string $storage_path;
|
||||
|
||||
public static function load()
|
||||
{
|
||||
self::$source_path = app_path('/Console/Commands/Grapper/Sofascore/grapped');
|
||||
|
||||
self::$storage_path = storage_path('zip_sofascore_data');
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$special = Nuh::$options['special'];
|
||||
$process = Nuh::$options['prc'];
|
||||
|
||||
switch($special){
|
||||
switch($process){
|
||||
case 1:
|
||||
if($debug){
|
||||
Notice::note('For speed in Statistiko'.PHP_EOL.'Count for every player how many time he has player per season and write it to DB', 'g');
|
||||
Notice::note('player active per season', 'y');
|
||||
}
|
||||
CountPlayerPerSeason::run();
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
case 2:
|
||||
if($debug){
|
||||
Notice::note('copy active tournament to local', 'y');
|
||||
}
|
||||
LeaguesToLocal::run();
|
||||
break;
|
||||
case 3:
|
||||
if($debug){
|
||||
Notice::note('create a zip archive', 'y');
|
||||
}
|
||||
CreateZip::run();
|
||||
break;
|
||||
case 4:
|
||||
if($debug){
|
||||
Notice::note('mail given folder', 'y');
|
||||
}
|
||||
SendMail::run();
|
||||
break;
|
||||
default:
|
||||
Notice::note('special ID not set process stopped', 'br', 1);
|
||||
Notice::note('run special "prc" id missing', 'br', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||
use App\Utilities\Notice;
|
||||
use App\Utilities\ZipFolder;
|
||||
|
||||
class CreateZip
|
||||
{
|
||||
|
||||
public static function run()
|
||||
{
|
||||
$days = LoadDays::load();
|
||||
|
||||
foreach ($days as $day) {
|
||||
ZipFolder::create($day);
|
||||
}
|
||||
|
||||
Notice::note('Archive created', 'g', 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
||||
|
||||
use App\Models\SofaScoreTournament;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LeaguesToLocal
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$tornaments = DB::connection('remote_mariadb')->table('sofa_score_tournaments')->where('enabled', 1)->pluck('id');
|
||||
|
||||
SofaScoreTournament::query()->update(['enabled' => 0]);
|
||||
|
||||
foreach ($tornaments as $tornament_id) {
|
||||
SofaScoreTournament::where('id', $tornament_id)->update(['enabled' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class CountPlayerPerSeason
|
||||
class PlayerPerSeason
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Special;
|
||||
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendMail
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$days = LoadDays::load();
|
||||
|
||||
foreach ($days as $day) {
|
||||
|
||||
$zip_file = Special::$storage_path.'/'.$day.'.zip';
|
||||
|
||||
Mail::send([], [], function ($message) use($day, $zip_file) {
|
||||
|
||||
$message->to("hermann.telser@gmail.com", "sofa archive ".$day)
|
||||
->cc("ubaldo.perrucci@gmail.com", "sofa archive ".$day)
|
||||
->subject("sofa archive $day")
|
||||
->attach($zip_file, [
|
||||
'mime' => 'application/x-zip-compressed',
|
||||
'as' => 'sofa archive '.$day.'.zip'
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Notice::note('Mail send', 'g');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Tools;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* FIFA World Cup 16
|
||||
* China Super League 649
|
||||
* Veikkausliiga 41
|
||||
*/
|
||||
|
||||
class LoadDays
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$today = Nuh::$options['t'] ?? 0;
|
||||
$yesterday = Nuh::$options['y'] ?? 0;
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
|
||||
if($today){
|
||||
$days[] = Carbon::now()->format('Y-m-d');
|
||||
}
|
||||
else if($yesterday){
|
||||
$days[] = Carbon::now()->subDay()->format('Y-m-d');
|
||||
}
|
||||
else {
|
||||
$days = SofaScoreDay::where('sport_id', $sport_id)->where('enabled', 1)->pluck('day')->toArray();
|
||||
}
|
||||
|
||||
if (! $days) {
|
||||
Notice::note(__file__.PHP_EOL.'no days', 'r', 1);
|
||||
}
|
||||
|
||||
return $days;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Tools;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
/**
|
||||
* FIFA World Cup 16
|
||||
* China Super League 649
|
||||
* Veikkausliiga 41
|
||||
*/
|
||||
|
||||
class LoadTournaments
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$print = Nuh::$options['p'] ?? 0;
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
$grps = Nuh::$options['grps'] ?? 0;
|
||||
|
||||
if($grps){
|
||||
$tornaments = SofaScoreTournament::select('name', 'tournament_id')->whereIn('tournament_id', explode(",", $grps))->where('enabled', 1)->get();
|
||||
}
|
||||
else{
|
||||
$tornaments = SofaScoreTournament::select('name', 'tournament_id')->where('sport_id', $sport_id)->where('enabled', 1)->get();
|
||||
}
|
||||
|
||||
if (! $tornaments) {
|
||||
Notice::note(__file__.PHP_EOL.'no tornaments', 'r', 1);
|
||||
}
|
||||
|
||||
return $tornaments;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class Nuh extends Command
|
||||
|
||||
public static $id = 0;
|
||||
|
||||
protected $signature = 'nuh {process=help} {--truncate} {--groups=0} {--days=0} {--day=0} {--id=0} {--special=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||
protected $signature = 'nuh {process=help} {--truncate} {--grps=0} {--days=0} {--day=0} {--id=0} {--prc=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -49,27 +49,29 @@ class Nuh extends Command
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= '--day (optional) grap day format "Y-m-d" or --t for today' . PHP_EOL;
|
||||
$txt .= '--days (optional) grap days back from yesterday' . PHP_EOL;
|
||||
$txt .= '--groups (optional) csv of tournament_id\'s' . PHP_EOL;
|
||||
$txt .= '--grps (optional) csv of tournament_id\'s' . PHP_EOL;
|
||||
$txt .= '--l langsam: calls between 0.5 an 10 sec' . PHP_EOL;
|
||||
$txt .= '--p will print days and tournaments and stop' . PHP_EOL;
|
||||
$txt .= '--special (generate data) [1 => count played/season]' . PHP_EOL;
|
||||
$txt .= '--prc (generate data) [1 => count played/season, 2=>Tournamet to local]' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||
$txt .= 'Options' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--p use proxy' . PHP_EOL;
|
||||
$txt .= '--d debug' . PHP_EOL;
|
||||
$txt .= '--f run also when odd' . PHP_EOL;
|
||||
$txt .= '--x generate supervisors' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--a all by id' . PHP_EOL;
|
||||
$txt .= '--b block update (reload all for txodds)' . PHP_EOL;
|
||||
$txt .= '--w laod this week (tx)' . PHP_EOL;
|
||||
$txt .= '--d debug' . PHP_EOL;
|
||||
$txt .= '--e echo client data' . PHP_EOL;
|
||||
$txt .= '--f force (whatever in script)' . PHP_EOL;
|
||||
$txt .= '--g by minor groups (tx)' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--m mail it' . PHP_EOL;
|
||||
$txt .= '--p use proxy' . PHP_EOL;
|
||||
$txt .= '--q print all queries' . PHP_EOL;
|
||||
$txt .= '--r read data from file ' . PHP_EOL;
|
||||
$txt .= '--s store data to file ' . PHP_EOL;
|
||||
$txt .= '--f force update market' . PHP_EOL;
|
||||
$txt .= '--q print all queries' . PHP_EOL;
|
||||
$txt .= '--e echo client data' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--w laod this week (tx)' . PHP_EOL;
|
||||
$txt .= '--x generate supervisors' . PHP_EOL;
|
||||
$txt .= '--y load yesterday' . PHP_EOL;
|
||||
$txt .= '--z show supervisors tasks' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user