Skip to content

Commit

Permalink
mid-build save files
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesText committed Jan 12, 2022
1 parent 382b020 commit 0d1e655
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 7 additions & 2 deletions functions.tactics.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ function conditional_tactics($config, $tactic_ids = FALSE) {
# process each tactic
foreach ($tactics as $t) {

$response['msg'] .= PHP_EOL . 'processed tactic_id ' . $t['tactic_id'] . PHP_EOL;

$update = FALSE;

/*
Expand Down Expand Up @@ -444,6 +446,9 @@ function conditional_tactics($config, $tactic_ids = FALSE) {
) {
if ($t['action'] == 'none') {
$t['status'] = 'executed';
} else if ($t['action'] == 'alert') {
$response['alert'] = TRUE;
$t['status'] = 'executed';
} else {
$t['status'] = 'actionable';
if (!is_null($t['from_amount'])) $amount = ($t['from_amount'] + 0) . ' ';
Expand Down Expand Up @@ -487,9 +492,9 @@ function conditional_tactics($config, $tactic_ids = FALSE) {
}

if (empty($tactics)) {
$response['msg'] .= 'no tactics found' . PHP_EOL;
$response['msg'] .= PHP_EOL . 'no tactics found' . PHP_EOL;
} else {
$response['msg'] .= count($tactics) . ' tactics found, ';
$response['msg'] .= PHP_EOL . count($tactics) . ' tactics found, ';
if (empty($response['result']))
$response['msg'] .= '0 updated' . PHP_EOL;
else
Expand Down
7 changes: 7 additions & 0 deletions functions.util.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ function process($response, $config) {

/* send notification message to alert bot */
if ($response['alert']) {
// html output is not developed yet
// if api returns html, this will throw an error
// so use strip_tags to remove html code
$response['msg'] = strip_tags($response['msg']);
// and also replace < and > symbols within plain text
$response['msg'] = str_replace('<=', 'LE', $response['msg']);
$response['msg'] = str_replace('<', 'LT', $response['msg']);
$response['msg'] = str_replace('>=', 'GE', $response['msg']);
$response['msg'] = str_replace('>', 'GT', $response['msg']);
$config['url'] =
$config['chat_url'] .
'/sendMessage?chat_id=' . $config['chat_id'] .
Expand Down
12 changes: 8 additions & 4 deletions tactics_process.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

include('includes.php');

$sep = '-------------------------------' . PHP_EOL;

$tactic_ids = FALSE;
if(isset($_GET['tactic_ids'])) $tactic_ids = $_GET['tactic_ids'];
$changed_ids = array();

$response = actionable_tactics($config, $tactic_ids);
$response['msg'] = 'actionable_tactics' . PHP_EOL . $response['msg'];
$response['msg'] = $sep . 'actionable_tactics' . PHP_EOL . $response['msg'];
process($response, $config);
foreach ($response['result'] as $key => $val)
array_push($changed_ids, $key);

$response = ordered_tactics($config, $tactic_ids);
$response['msg'] = 'ordered_tactics' . PHP_EOL . $response['msg'];
$response['msg'] = $sep . 'ordered_tactics' . PHP_EOL . $response['msg'];
process($response, $config);
foreach ($response['result'] as $key => $val)
array_push($changed_ids, $key);

$response = conditional_tactics($config, $tactic_ids);
$response['msg'] = 'conditional_tactics' . PHP_EOL . $response['msg'];
$response['msg'] = $sep . 'conditional_tactics' . PHP_EOL . $response['msg'];
process($response, $config);
foreach ($response['result'] as $key => $val)
array_push($changed_ids, $key);
Expand All @@ -28,7 +30,7 @@
$changed_ids = dedupe_array($changed_ids);
$changed_ids = implode(',', $changed_ids);
$response = trigger_tactics($config, $changed_ids);
$response['msg'] = 'trigger_tactics ' . PHP_EOL . $response['msg'];
$response['msg'] = $sep . 'trigger_tactics ' . PHP_EOL . $response['msg'];
process($response, $config);
if ($response['count']) {
$tactic_ids = implode(',', $response['result']);
Expand All @@ -38,4 +40,6 @@
}
}

echo $sep;

include('system_metrics.php');

0 comments on commit 0d1e655

Please sign in to comment.