Skip to content

Commit

Permalink
Update handling of response objects, since their format has changed t…
Browse files Browse the repository at this point in the history
…o match other OGD APIs.
  • Loading branch information
LswaN58 committed Jun 5, 2024
1 parent 3f6e846 commit a74d60e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions site/gamedata.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
$response_obj = services\getGameFileInfoByMonth($game_id);

if (isset($response_obj)) {
if ($response_obj->{'success'}) {
$game_files = GameFileInfo::fromObj($response_obj->{'data'});
if ($response_obj->{'status'} == "SUCCESS") {
$game_files = GameFileInfo::fromObj($response_obj->{'val'});
if (!isset($game_files) || $game_files == null) {
$err_str = "Got empty game_files from request that had success=".$response_obj->{'success'}." and data=".json_encode($response_obj->{'data'});
error_log($err_str);
Expand Down Expand Up @@ -79,12 +79,12 @@
$feature_files = $game_files->getFeatureFiles() ? $game_files->getFeatureFiles(): [];
}
else {
$err_str = "getGameFileInfoByMonth request, with year=null and month=null, was unsuccessful! Damn, maybe the authors shouldn't have written in a request for a specific month's data, but failed to supply a month! Who'd have thought?!?";
$err_str = "getGameFileInfoByMonth request, with year=null and month=null, was unsuccessful:\n".$response_obj->{'msg'}."\nDamn, maybe the authors shouldn't have written in a request for a specific month's data, but failed to supply a month! Who'd have thought?!?";
error_log($err_str);
}
}
else {
$err_str = "Got no response object!";
$err_str = "getGameFileInfoByMonth request, with year=null and month=null, got no response object!";
error_log($err_str);
}

Expand Down
14 changes: 12 additions & 2 deletions site/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@
// Get game usage from api for each game
$response_obj = services\getGameUsage($key);
$game_usage = null;
if (isset($response_obj) && $response_obj->{'success'}) {
$game_usage = GameUsage::fromObj($response_obj->{'data'});
if (isset($response_obj)) {
if ($response_obj->{'status'} == "SUCCESS") {
$game_usage = GameUsage::fromObj($response_obj->{'val'});
}
else {
$err_str = "getGameUsage request, with year=".$key.", was unsuccessful:\n".$response_obj->{'msg'};
error_log($err_str);
}
}
else {
$err_str = "getGameUsage request, with game_id=".$key.", got no response object!";
error_log($err_str);
}

$game_card = new GameCard(Game::fromJson($key, json_encode($value)), $game_usage);
Expand Down

0 comments on commit a74d60e

Please sign in to comment.