Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
fix share count in case of api error
Browse files Browse the repository at this point in the history
If an API throws an error, the share count will be omitted in the
backend response.
  • Loading branch information
pmb0 committed Dec 2, 2014
1 parent ec3cd4e commit 5a2d47b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/Heise/Shariff.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Heise::Shariff::Cache;
use Mojo::Date;
use Mojo::Loader;

our $VERSION = '1.08';
our $VERSION = '1.09';

has service_namespaces => sub {['Heise::Shariff::Service']};

Expand Down Expand Up @@ -67,8 +67,10 @@ sub startup {
for (my $i = 0; $i < @transactions; $i++) {
# warn dumper $transactions[$i]->res;
my $service = $services[$i];
$counts{ $service->get_name } =
$service->extract_count($transactions[$i]->res)

if (my $value = $service->extract_count($transactions[$i]->res)) {
$counts{ $service->get_name } = $value;
}
}

my $mtime = time;
Expand Down
2 changes: 1 addition & 1 deletion lib/Heise/Shariff/Service/Facebook.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sub extract_count {
return $res->json->[0]->{share_count};
} else {
warn dumper($res);
return 0;
return undef;
}
}

Expand Down

0 comments on commit 5a2d47b

Please sign in to comment.