This commit is contained in:
salam committed 2026-06-08 15:12:27 +02:00
1 parent 336af556a1
commit 8578ec96bb
6 files changed
+54 -71

No files matched your search

+8
View File
@@ -1,3 +1,11 @@
## REMOTE DB SETTING
# make port changes in .env file to forward
# use remote db with mariadb
ssh -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
# use remote db with mongodb
ssh -L 27027:127.0.0.1:27017 -p 58371 root@162.55.242.190
importing importing
https://github.com/christophrumpel/laravel-import-million-rows https://github.com/christophrumpel/laravel-import-million-rows
+4 -7
View File
@@ -17,7 +17,7 @@ class Curl
if ($debug) { if ($debug) {
if ($proxy) { if ($proxy) {
Notice::note($url.PHP_EOL.Nuh::$options['proxy'], 'b'); Notice::note($url . PHP_EOL . Nuh::$options['proxy'], 'b');
} else { } else {
Notice::note($url, 'g'); Notice::note($url, 'g');
} }
@@ -27,7 +27,7 @@ class Curl
if ($debug) { if ($debug) {
Notice::note('data read localy', 'g'); Notice::note('data read localy', 'g');
} }
$filename = app_path().self::$testfiles.strtolower(str_replace(' ', '_', Nuh::$options['name'])).'.json'; $filename = app_path() . self::$testfiles . strtolower(str_replace(' ', '_', Nuh::$options['name'])) . '.json';
$file = file_get_contents($filename); $file = file_get_contents($filename);
@@ -37,7 +37,7 @@ class Curl
$file = self::fetch_data_with_retries($url, $_config); $file = self::fetch_data_with_retries($url, $_config);
if ($save) { if ($save) {
$filename = app_path().self::$testfiles.strtolower(str_replace(' ', '_', Nuh::$options['name'])).'.json'; $filename = app_path() . self::$testfiles . strtolower(str_replace(' ', '_', Nuh::$options['name'])) . '.json';
file_put_contents($filename, $file); file_put_contents($filename, $file);
@@ -125,20 +125,17 @@ class Curl
$attempt++; $attempt++;
$curl_errorno = curl_errno($ch); $curl_errorno = curl_errno($ch);
if ($debug && $curl_errorno) { if ($debug && $curl_errorno) {
Notice::note('curl_errorno: '.self::curlerrorcode($curl_errorno)); Notice::note('curl_errorno: ' . self::curlerrorcode($curl_errorno));
} }
if ($debug) { if ($debug) {
echo "Attempt $attempt failed. Retrying...\n"; echo "Attempt $attempt failed. Retrying...\n";
} }
sleep(2); // Optional: Sleep between retries sleep(2); // Optional: Sleep between retries
} else { } else {
curl_close($ch);
return $response; return $response;
} }
} }
echo "All attempts failed.\n"; echo "All attempts failed.\n";
curl_close($ch);
return null; // Return null if all retries fail return null; // Return null if all retries fail
} }
@@ -32,7 +32,11 @@ class Events
// to grap event id // to grap event id
// https://www.sofascore.com/api/v1/unique-tournament/2480/scheduled-events/2022-05-19 // https://www.sofascore.com/api/v1/unique-tournament/2480/scheduled-events/2022-05-19
// https://www.sofascore.com/api/v1/unique-tournament/2480/scheduled-events/2026-05-31
// per event
// https://www.sofascore.com/api/v1/event/16198485/statistics
// https://www.sofascore.com/api/v1/event/16198485/odds/1/all
$years_back = 7; $years_back = 7;
$dates = Carbon::now()->subYears($years_back); $dates = Carbon::now()->subYears($years_back);
@@ -18,24 +18,32 @@ class Tournament
{ {
public static function load() public static function load()
{ {
$days = 1;
$debug = Nuh::$options['d'] ?? 0; $debug = Nuh::$options['d'] ?? 0;
$force = Nuh::$options['f'] ?? 0;
$sport_id = Nuh::$options['sport_id']; $sport_id = Nuh::$options['sport_id'];
$sport = Sport::where('id', $sport_id)->first(); $sport = Sport::where('id', $sport_id)->first();
$dates = Carbon::now(); // start yesterday
$grapping_date = Carbon::now()->subDay();
while ($dates >= Carbon::now()->subYears($sport->ss_grap_years)) { $days++;
$days_back = Carbon::now()->subDays($days);
while ($grapping_date >= $days_back) {
$tournaments_counter = 0; $tournaments_counter = 0;
$day = $dates->format('Y-m-d'); $day = $grapping_date->format('Y-m-d');
/** /**
* grap only one time/sport check * grap only one time/sport check
*/ */
if (! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) { if ($force || ! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
if ($debug) { if ($debug) {
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'g'); Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'g');
@@ -168,7 +176,7 @@ class Tournament
Notice::note('Having Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'b'); Notice::note('Having Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'b');
} }
} }
$dates->subDay(); $grapping_date->subDay();
} }
} }
} }
+4 -6
View File
@@ -16,14 +16,14 @@ class Xml
$save = Nuh::$options['s'] ?? 0; $save = Nuh::$options['s'] ?? 0;
$read = Nuh::$options['r'] ?? 0; $read = Nuh::$options['r'] ?? 0;
$filename = app_path().'/Console/Commands/TestFiles/'.strtolower(str_replace(' ', '_', Nuh::$options['name'])).'.xml'; $filename = app_path() . '/Console/Commands/TestFiles/' . strtolower(str_replace(' ', '_', Nuh::$options['name'])) . '.xml';
if ($debug) { if ($debug) {
Notice::note("Loading URL\n".$url); Notice::note("Loading URL\n" . $url);
} }
if ($save || $read) { if ($save || $read) {
Notice::note("FILE NAME\n".$filename); Notice::note("FILE NAME\n" . $filename);
} }
if ($read) { if ($read) {
@@ -96,16 +96,14 @@ class Xml
echo "Attempt $attempt failed. Retrying...\n"; echo "Attempt $attempt failed. Retrying...\n";
sleep(2); // Optional: Sleep between retries sleep(2); // Optional: Sleep between retries
} else { } else {
curl_close($ch);
if (mb_substr($response, 0, 1) != '<') { if (mb_substr($response, 0, 1) != '<') {
Log::debug('INVALID XML '.$url.'----'.$response); Log::debug('INVALID XML ' . $url . '----' . $response);
} else { } else {
return new SimpleXMLElement($response); return new SimpleXMLElement($response);
} }
} }
} }
echo "All attempts failed.\n"; echo "All attempts failed.\n";
curl_close($ch);
return null; // Return null if all retries fail return null; // Return null if all retries fail
} }
+21 -53
View File
@@ -42,25 +42,25 @@ return [
'synchronous' => null, 'synchronous' => null,
], ],
'mysql' => [ // 'mysql' => [
'driver' => 'mysql', // 'driver' => 'mysql',
'url' => env('DB_URL'), // 'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'), // 'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'), // 'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'), // 'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'), // 'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''), // 'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''), // 'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'), // 'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), // 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '', // 'prefix' => '',
'prefix_indexes' => true, // 'prefix_indexes' => true,
'strict' => false, // 'strict' => false,
'engine' => null, // 'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([ // 'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), // PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [], // ]) : [],
], // ],
'mariadb' => [ 'mariadb' => [
'driver' => 'mariadb', 'driver' => 'mariadb',
@@ -78,39 +78,6 @@ return [
'prefix_indexes' => true, 'prefix_indexes' => true,
'strict' => false, 'strict' => false,
'engine' => null, 'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
], ],
'mongodb' => [ 'mongodb' => [
@@ -119,6 +86,7 @@ return [
'database' => env('MONGODB_DATABASE', 'nuhodds'), 'database' => env('MONGODB_DATABASE', 'nuhodds'),
], ],
// ssh -L 27017:127.0.0.1:27017 ssh -p 58371 root@162.55.242.190
], ],
/* /*
@@ -154,7 +122,7 @@ return [
'options' => [ 'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'), 'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'), 'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')) . '-database-'),
'persistent' => env('REDIS_PERSISTENT', false), 'persistent' => env('REDIS_PERSISTENT', false),
], ],