Skip to content
This repository has been archived by the owner on Nov 28, 2017. It is now read-only.

Commit

Permalink
Don't send in for a first time
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Chekalskiy committed May 11, 2015
1 parent 3815d7e commit e0f2ca6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Reviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Reviewer
*/
protected $appId;

/**
* Is sending fired for a first time
*
* @var boolean
*/
protected $firstTime = false;

/**
* Exception cathced during the initialization
*
Expand Down Expand Up @@ -82,6 +89,10 @@ public function __construct($appId)
throw new Exception("Please make '{$databaseDir}' dir writable");
}

if (!file_exists($databaseDir . '/reviews.dat')) {
$this->firstTime = true;
}

try {
$this->storage = Flintstone::load('reviews', ['dir' => $databaseDir]);
} catch (FlintstoneException $e) {
Expand Down Expand Up @@ -233,7 +244,9 @@ public function sendReviews($reviews)
]
]);

$slack->send();
if ($this->firstTime === true) {
$slack->send();
}

$this->storage->set("r{$review['id']}", 1);
} catch (Exception $e) {
Expand Down

0 comments on commit e0f2ca6

Please sign in to comment.