Skip to content

Commit

Permalink
Effiana fix migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandOrientedTmp committed Jan 11, 2019
1 parent bff4b65 commit 0c4952d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Controller/Admin/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@ public function index()
->createQueryBuilder('cronJob')
->orderBy('cronJob.id', 'ASC')
->getQuery()->getArrayResult();

$scheduledCommandIds = array_map(function($item) {
return $item['id'];
}, $scheduledCommands);

$lastScheduledCommands = $em->getRepository('EffianaCronBundle:CronReport')
->createQueryBuilder('cronReport', 'cronReport.jobId')
->select('cronReport.jobId, MAX(cronReport.runAt) as runAt')
->andWhere('cronReport.jobId IN(:scheduledCommandIds)')
->groupBy('cronReport.jobId')
->setParameters([
'scheduledCommandIds' => $scheduledCommandIds
])
->getQuery()->getArrayResult();

$scheduledCommands = array_map(function($item) use($lastScheduledCommands) {
$runAt = null;
if(isset($lastScheduledCommands[$item['id']]['runAt'])) {
$runAt = $lastScheduledCommands[$item['id']]['runAt'];
}
$item['runAt'] = $runAt;
return $item;
}, $scheduledCommands);

return $this->render('@EffianaCron/Admin/index.html.twig', [
'scheduledCommands' => $scheduledCommands
]);
Expand Down
8 changes: 7 additions & 1 deletion Entity/CronReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ class CronReport
protected $output;

/**
* @ORM\ManyToOne(targetEntity="CronJob", inversedBy="reports")
* @ORM\ManyToOne(targetEntity="Effiana\CronBundle\Entity\CronJob", inversedBy="reports")
* @ORM\JoinColumn(name="job_id", referencedColumnName="id", onDelete="CASCADE")
* @var CronJob
*/
protected $job;

/**
* @ORM\Column(type="integer", name="job_id")
* @var integer
*/
protected $jobId;

/**
* @return int
*/
Expand Down
4 changes: 4 additions & 0 deletions Resources/views/Admin/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<th>{{ "detail.name"|trans }}</th>
<th>{{ "detail.command"|trans }}</th>
<th>{{ "detail.cronExpression"|trans }}</th>
<th>{{ "detail.lastExecution"|trans }}</th>
<th>{{ "detail.actions"|trans }}</th>
</tr>
</thead>
Expand All @@ -49,6 +50,9 @@
<td>
{{ command.schedule }}
</td>
<td>
{{ command.runAt }}
</td>
<td style="min-width: 90px;">
<a href="{{ path('effiana_cron_bundle_edit', {id: command.id}) }}" >
<span class="text-info glyphicon glyphicon-pencil"></span> <span class="sr-only">{{ "action.edit"|trans }}</span>
Expand Down

0 comments on commit 0c4952d

Please sign in to comment.