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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user