Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ushahidi/pingapp into email-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kobia committed Oct 8, 2013
2 parents a41b769 + 3b285b5 commit c006b17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 15 additions & 0 deletions application/classes/PingApp/Ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ public static function process($ping_id = 0)
{
$_ping->status = 'cancelled';
$_ping->save();

// Cancel the Parent Too
$parent = $_ping->parent;
if ( $parent->loaded() )
{
$parent->status = 'cancelled';
$parent->save();

// If there are any other children out there
foreach ($parent->children->find_all() as $child)
{
$child->status = 'cancelled';
$child->save();
}
}
}

// Ping the Secondaries
Expand Down
9 changes: 5 additions & 4 deletions application/classes/Task/Ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected function _requeue()
$pings = ORM::factory('Ping')
->select('pongs.pongs')
->where('sent', '=', 1)
->where('status', '=', 'pending')
->where('parent_id', '=', 0)
->join(array($pongs, 'pongs'), 'LEFT')
->on('ping.contact_id', '=', 'pongs.contact_id')
Expand Down Expand Up @@ -137,12 +138,12 @@ protected function _process()
{
try
{
// Pop An Element from the Queue (Block for 3 seconds)
$item = $redis->blPop('pingapp_pings', 3);
// Pop An Element from the Queue
$item = $redis->lPop('pingapp_pings');

if ( isset($item[1]) )
if ( (int) $item )
{
PingApp_Ping::process((int) $item[1]);
PingApp_Ping::process((int) $item);
}
else
{
Expand Down

0 comments on commit c006b17

Please sign in to comment.