Web notifications small fixes. Issue #156.
This commit is contained in:
parent
3f56e4cc54
commit
56fc76d4e5
7 changed files with 36 additions and 69 deletions
|
|
@ -2,13 +2,7 @@
|
|||
|
||||
namespace PHPCensor\Service;
|
||||
|
||||
use PHPCensor\Config;
|
||||
use Pheanstalk\Pheanstalk;
|
||||
use Pheanstalk\PheanstalkInterface;
|
||||
use PHPCensor\BuildFactory;
|
||||
use PHPCensor\Model\Build;
|
||||
use PHPCensor\Model\Project;
|
||||
use PHPCensor\Store\BuildStore;
|
||||
|
||||
/**
|
||||
* A service that listens for creation, duplication and deletion of builds for web notification UI.
|
||||
|
|
@ -18,8 +12,11 @@ class WebNotificationService
|
|||
/**
|
||||
* Similar to BuildController::formatBuilds() but uses
|
||||
* pure object to be used for rendering web notifications.
|
||||
*
|
||||
* @param array $builds
|
||||
*
|
||||
* @return array Formatted builds
|
||||
*
|
||||
* @see \PHPCensor\Controller\WidgetLastBuildsController::webNotificationUpdate().
|
||||
*/
|
||||
public static function formatBuilds($builds)
|
||||
|
|
@ -37,7 +34,9 @@ class WebNotificationService
|
|||
|
||||
/**
|
||||
* Provides structured keys for web notification.
|
||||
*
|
||||
* @param Build $build
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function formatBuild($build)
|
||||
|
|
@ -45,15 +44,11 @@ class WebNotificationService
|
|||
if (empty($build) || is_null($build)) {
|
||||
return [];
|
||||
}
|
||||
$status = $build->getStatus();
|
||||
$datePerformed = '';
|
||||
$dateFinished = '';
|
||||
|
||||
/*
|
||||
BUG: Lang::out() automatically renders the values for
|
||||
either 'created_x' or 'started_x' instead of just
|
||||
returning them.
|
||||
*/
|
||||
$status = $build->getStatus();
|
||||
$datePerformed = '';
|
||||
$dateFinished = '';
|
||||
|
||||
if ($status === Build::STATUS_PENDING) {
|
||||
$datePerformed = 'Created: ' . $build->getCreateDate()->format('H:i');
|
||||
} elseif ($status === Build::STATUS_RUNNING) {
|
||||
|
|
@ -66,13 +61,9 @@ class WebNotificationService
|
|||
|
||||
return [
|
||||
'branch' => $build->getBranch(),
|
||||
'url' => APP_URL .
|
||||
'build/view/' .
|
||||
$build->getId(),
|
||||
'url' => APP_URL . 'build/view/' . $build->getId(),
|
||||
'committer_email' => $build->getCommitterEmail(),
|
||||
'img_src' => 'https://www.gravatar.com/avatar/' .
|
||||
md5($build->getCommitterEmail()) .
|
||||
'?d=mm&s=40',
|
||||
'img_src' => 'https://www.gravatar.com/avatar/' . md5($build->getCommitterEmail()) . '?d=mm&s=40',
|
||||
'project_title' => $build->getProject()->getTitle(),
|
||||
'status' => $status,
|
||||
'date_performed' => $datePerformed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue