Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-04-13 00:52:21 +02:00
parent aeb7599811
commit 2ea0cc28a6
4 changed files with 2355 additions and 8 deletions

View File

@@ -15,10 +15,72 @@
},
"autoload": {
"controls": {
"class.Allegro.php": {
"type": "-",
"size": 6456,
"lmtime": 0,
"modified": false
},
"class.Api.php": {
"type": "-",
"size": 11018,
"lmtime": 0,
"modified": false
},
"class.Campaigns.php": {
"type": "-",
"size": 2817,
"lmtime": 0,
"modified": false
},
"class.Cron.php": {
"type": "-",
"size": 20273,
"lmtime": 1744063175514,
"modified": false
},
"class.Products.php": {
"type": "-",
"size": 7477,
"lmtime": 1741427168653,
"size": 8787,
"lmtime": 1744064045288,
"modified": false
},
"class.Site.php": {
"type": "-",
"size": 494,
"lmtime": 0,
"modified": false
},
"class.Users.php": {
"type": "-",
"size": 3091,
"lmtime": 0,
"modified": false
}
},
"factory": {
"class.Campaigns.php": {
"type": "-",
"size": 1089,
"lmtime": 0,
"modified": false
},
"class.Cron.php": {
"type": "-",
"size": 26120,
"lmtime": 0,
"modified": false
},
"class.Products.php": {
"type": "-",
"size": 4561,
"lmtime": 1744062307424,
"modified": false
},
"class.Users.php": {
"type": "-",
"size": 1709,
"lmtime": 0,
"modified": false
}
}
@@ -80,7 +142,22 @@
"lmtime": 0,
"modified": false
},
"templates": {},
"templates": {
"products": {
"main_view.php": {
"type": "-",
"size": 9119,
"lmtime": 1744063449814,
"modified": false
},
"product_history.php": {
"type": "-",
"size": 5117,
"lmtime": 0,
"modified": false
}
}
},
"upload": {},
"xml": {}
}

View File

@@ -39,7 +39,7 @@ class Api
$campaign_history_data['roas_all_time'] = $campaign['roasAllTime'];
$campaign_history_data['budget'] = str_replace( ' zł', '' , $campaign['budget'] );
$campaign_history_data['money_spent'] = floatval( preg_replace(['/[^0-9,]/', '/,/'], ['', '.'], $campaign['spend30Days'] ) );
$campaign_history_data['conversion_value'] = $campaign['conversionValue30Days'];
$campaign_history_data['conversion_value'] = preg_replace( '/[^\d,.-]/', '', $campaign['conversionValue30Days'] );
if ( isset( $campaign['biddingStrategy'] ) and $campaign['biddingStrategy'] == 'MAXIMIZE_CONVERSIONS' )
{
@@ -121,7 +121,7 @@ class Api
$phrase_data['clicks'] = $phrase['Clicks'];
$phrase_data['cost'] = $phrase['Cost'];
$phrase_data['conversions'] = $phrase['Conversions'];
$phrase_data['conversions_value'] = $phrase['ConversionValue'];
$phrase_data['conversions_value'] = preg_replace( '/[^\d,.-]/', '', $phrase['ConversionValue'] );
$phrase_data['updated'] = 1;
if ( $mdb -> count( 'phrases_history', [ 'AND' => [ 'phrase_id' => $phrase_id, 'date_add' => $data['date'] ] ] ) )
@@ -178,7 +178,7 @@ class Api
$json = file_get_contents( 'php://input' );
$data = json_decode( $json, true );
// file_put_contents( 'tmp/products_data_save.txt', print_r( $data, true ) );
if ( $data['client_id'] and $data['date'] )
{
foreach ( $data['data'] as $offer )
@@ -216,9 +216,9 @@ class Api
$offer_data['impressions'] = $offer['Impressions'];
$offer_data['clicks'] = $offer['Clicks'];
$offer_data['ctr'] = round( $offer['Clicks'] / $offer['Impressions'], 4 ) * 100;
$offer_data['cost'] = $offer['Cost'];
$offer_data['cost'] = preg_replace( '/[^\d,.-]/', '', $offer['Cost'] );
$offer_data['conversions'] = $offer['Conversions'];
$offer_data['conversions_value'] = $offer['ConversionValue'];
$offer_data['conversions_value'] = preg_replace( '/[^\d,.-]/', '', $offer['ConversionValue'] );
$offer_data['updated'] = 1;
if ( $mdb -> count( 'products_history', [ 'AND' => [ 'product_id' => $offer_id, 'date_add' => $data['date'] ] ] ) )

View File

@@ -75,6 +75,8 @@ class Products
$custom_label_4_color = 'background-color:rgb(255, 0, 0); color: #FFF;';
else if ( $custom_label_4 == 'zombie' )
$custom_label_4_color = 'background-color:rgb(58, 58, 58); color: #FFF;';
else if ( $custom_label_4 == 'pla' )
$custom_label_4_color = 'background-color:rgb(74, 63, 136); color: #FFF;';
$data['data'][] = [
$row['product_id'],

2268
tmp/products_data_save.txt Normal file

File diff suppressed because it is too large Load Diff