Add incident column for when an incident occurred at (#2212)
Add incident column for when an incident occurred at. Closes #2208 [ci skip] [skip ci]
This commit is contained in:
@@ -76,7 +76,7 @@ class IncidentController extends AbstractApiController
|
||||
Binput::get('component_status'),
|
||||
Binput::get('notify', true),
|
||||
Binput::get('stickied', false),
|
||||
Binput::get('created_at'),
|
||||
Binput::get('occurred_at'),
|
||||
Binput::get('template'),
|
||||
Binput::get('vars', [])
|
||||
));
|
||||
@@ -107,7 +107,7 @@ class IncidentController extends AbstractApiController
|
||||
Binput::get('component_status'),
|
||||
Binput::get('notify', true),
|
||||
Binput::get('stickied', false),
|
||||
Binput::get('created_at'),
|
||||
Binput::get('occurred_at'),
|
||||
Binput::get('template'),
|
||||
Binput::get('vars', [])
|
||||
));
|
||||
|
||||
@@ -127,11 +127,11 @@ class DashboardController extends Controller
|
||||
*/
|
||||
protected function getIncidents()
|
||||
{
|
||||
$allIncidents = Incident::notScheduled()->whereBetween('created_at', [
|
||||
$allIncidents = Incident::notScheduled()->whereBetween('occurred_at', [
|
||||
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
|
||||
$this->startDate->format('Y-m-d').' 23:59:59',
|
||||
])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
||||
return (new Date($incident->created_at))
|
||||
])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
||||
return (new Date($incident->occurred_at))
|
||||
->setTimezone($this->dateTimeZone)->toDateString();
|
||||
});
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class IncidentController extends Controller
|
||||
Binput::get('component_status'),
|
||||
Binput::get('notify', false),
|
||||
Binput::get('stickied', false),
|
||||
Binput::get('created_at'),
|
||||
Binput::get('occurred_at'),
|
||||
null,
|
||||
[]
|
||||
));
|
||||
@@ -259,7 +259,7 @@ class IncidentController extends Controller
|
||||
Binput::get('component_status'),
|
||||
Binput::get('notify', true),
|
||||
Binput::get('stickied', false),
|
||||
Binput::get('created_at'),
|
||||
Binput::get('occurred_at'),
|
||||
null,
|
||||
[]
|
||||
));
|
||||
|
||||
@@ -18,6 +18,11 @@ use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* This is the feed controller.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class FeedController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -80,12 +85,12 @@ class FeedController extends Controller
|
||||
{
|
||||
if ($group->exists) {
|
||||
$group->components->map(function ($component) use ($isRss) {
|
||||
$component->incidents()->visible()->orderBy('created_at', 'desc')->get()->map(function ($incident) use ($isRss) {
|
||||
$component->incidents()->visible()->orderBy('occurred_at', 'desc')->get()->map(function ($incident) use ($isRss) {
|
||||
$this->feedAddItem($incident, $isRss);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Incident::visible()->orderBy('created_at', 'desc')->get()->map(function ($incident) use ($isRss) {
|
||||
Incident::visible()->orderBy('occurred_at', 'desc')->get()->map(function ($incident) use ($isRss) {
|
||||
$this->feedAddItem($incident, $isRss);
|
||||
});
|
||||
}
|
||||
@@ -105,7 +110,7 @@ class FeedController extends Controller
|
||||
$incident->name,
|
||||
Config::get('setting.app_name'),
|
||||
Str::canonicalize(cachet_route('incident', [$incident->id])),
|
||||
$isRss ? $incident->created_at->toRssString() : $incident->created_at->toAtomString(),
|
||||
$isRss ? $incident->occurred_at->toRssString() : $incident->occurred_at->toAtomString(),
|
||||
$isRss ? $incident->message : Markdown::convertToHtml($incident->message)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@ class StatusPageController extends AbstractApiController
|
||||
|
||||
$incidentVisibility = Auth::check() ? 0 : 1;
|
||||
|
||||
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisibility)->whereBetween('created_at', [
|
||||
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisibility)->whereBetween('occurred_at', [
|
||||
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
|
||||
$startDate->format('Y-m-d').' 23:59:59',
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->load('updates')->groupBy(function (Incident $incident) {
|
||||
return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->created_at)->toDateString();
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
||||
return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->occurred_at)->toDateString();
|
||||
});
|
||||
|
||||
// Add in days that have no incidents
|
||||
@@ -109,7 +109,7 @@ class StatusPageController extends AbstractApiController
|
||||
->withDaysToShow($daysToShow)
|
||||
->withAllIncidents($allIncidents)
|
||||
->withCanPageForward((bool) $today->gt($startDate))
|
||||
->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)
|
||||
->withCanPageBackward(Incident::notScheduled()->where('occurred_at', '<', $startDate->format('Y-m-d'))->count() > 0)
|
||||
->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())
|
||||
->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user