Skip to content

Commit

Permalink
Merge pull request #183 from bcgov/jp-0002
Browse files Browse the repository at this point in the history
Dev - System Notification in the Event of Data Interface Errors [jp-0002]
  • Loading branch information
jp-Telus authored May 31, 2023
2 parents b873e60 + 23851e8 commit 6b2b82d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
17 changes: 14 additions & 3 deletions app/Console/Commands/ImportNonGovPledgeHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ protected function UpdateNonGovPledgeHistory($in_year)
$filter = '(yearcd eq '. $in_year .')';

// try {
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_NON_GOV_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_NON_GOV_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);

if ($response->successful()) {

$row_count = json_decode($response->body())->{'@odata.count'};

Expand Down Expand Up @@ -220,6 +222,15 @@ protected function UpdateNonGovPledgeHistory($in_year)

}

} else {

$this->status = 'Error';
$this->LogMessage( $response->status() . ' - ' . $response->body() );

throw new Exception( $response->status() . ' - ' . $response->body() );

}

// } catch (\Exception $ex) {

// // write to log message
Expand Down
32 changes: 24 additions & 8 deletions app/Console/Commands/ImportPledgeHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ protected function UpdatePledgeHistoryVendor()
{

// try {
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_VNDR_BI_ENDPOINT') .'?$count=true&$top=1');
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_VNDR_BI_ENDPOINT') .'?$count=true&$top=1');

if ($response->successful()) {
$row_count = json_decode($response->body())->{'@odata.count'};

if ($row_count > 0) {
// Truncate Pledge History table when records returned from BI
PledgeHistoryVendor::truncate();
Expand Down Expand Up @@ -252,6 +253,14 @@ protected function UpdatePledgeHistoryVendor()

}

} else {

$this->status = 'Error';
$this->LogMessage( $response->status() . ' - ' . $response->body() );

throw new Exception( $response->status() . ' - ' . $response->body() );
}

// } catch (\Exception $ex) {

// $this->status = 'Error';
Expand All @@ -272,10 +281,11 @@ protected function UpdatePledgeHistory($in_year)
$filter = '(yearcd eq '. $in_year .')';

// try {
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);

if ($response->successful()) {
$row_count = json_decode($response->body())->{'@odata.count'};

$size = 10000;
Expand Down Expand Up @@ -373,10 +383,16 @@ protected function UpdatePledgeHistory($in_year)
$this->status = 'Error';
$this->LogMessage( $response->status() . ' - ' . $response->body() );

}
throw new Exception( $response->status() . ' - ' . $response->body() );

}
}

} else {

throw new Exception( $response->status() . ' - ' . $response->body() );
}

// } catch (\Exception $ex) {

// // write to log message
Expand Down
2 changes: 1 addition & 1 deletion app/MicrosoftGraph/SendEmailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function send()
protected function sendMailUsingSMPTServer()
{

$this->subject = "PECSF [". App::environment() . "] -- The Process ('" . $this->job_id . " - ". $this->job_name . ")' was failed to complete.";
$this->subject = "PECSF [". App::environment() . "] -- The Process (" . $this->job_id . " - ". $this->job_name . ") was failed to complete.";

$this->body = "<p>";
$this->body .= "Process ID : " . $this->job_id . "</br>";
Expand Down

0 comments on commit 6b2b82d

Please sign in to comment.