From 0851427f2d495f8bfe3d161f1fe5337ee13dbcec Mon Sep 17 00:00:00 2001 From: James Brooks Date: Fri, 4 Sep 2015 08:18:10 +0100 Subject: [PATCH 1/3] Fixes #934 - Scheduled items now drop into the right days --- app/Http/Controllers/HomeController.php | 8 +++++- app/Models/Incident.php | 2 +- app/Presenters/IncidentPresenter.php | 28 ++++++++++++++++++++ resources/views/partials/incidents.blade.php | 3 +-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index c928ada3..4df9d1a3 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -65,7 +65,13 @@ class HomeController extends AbstractController $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [ $startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00', $startDate->format('Y-m-d').' 23:59:59', - ])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) { + ])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) { + // If it's scheduled, get the scheduled at date. + if ($incident->is_scheduled) { + return (new Date($incident->scheduled_at)) + ->setTimezone($dateTimeZone)->toDateString(); + } + return (new Date($incident->created_at)) ->setTimezone($dateTimeZone)->toDateString(); }); diff --git a/app/Models/Incident.php b/app/Models/Incident.php index 82aa4581..e7922bac 100644 --- a/app/Models/Incident.php +++ b/app/Models/Incident.php @@ -141,7 +141,7 @@ class Incident extends Model implements HasPresenter */ public function getIsScheduledAttribute() { - return $this->getOriginal('scheduled_at'); + return $this->getOriginal('scheduled_at') !== null; } /** diff --git a/app/Presenters/IncidentPresenter.php b/app/Presenters/IncidentPresenter.php index ad044303..6613f26e 100644 --- a/app/Presenters/IncidentPresenter.php +++ b/app/Presenters/IncidentPresenter.php @@ -129,6 +129,34 @@ class IncidentPresenter extends AbstractPresenter return $this->wrappedObject->scheduled_at->setTimezone($this->setting->get('app_timezone'))->format('d/m/Y H:i'); } + /** + * Returns a formatted timestamp for use within the timeline. + * + * @return string + */ + public function timestamp_formatted() + { + if ($this->wrappedObject->is_scheduled) { + return $this->scheduled_at_formatted; + } else { + return $this->created_at_formatted; + } + } + + /** + * Return the iso timestamp for use within the timeline. + * + * @return string + */ + public function timestamp_iso() + { + if ($this->wrappedObject->is_scheduled) { + return $this->scheduled_at_iso; + } else { + return $this->created_at_iso; + } + } + /** * Present the status with an icon. * diff --git a/resources/views/partials/incidents.blade.php b/resources/views/partials/incidents.blade.php index b847b71b..63f65f21 100644 --- a/resources/views/partials/incidents.blade.php +++ b/resources/views/partials/incidents.blade.php @@ -21,8 +21,7 @@ {{ $incident->name }}{{ $incident->isScheduled ? trans("cachet.incidents.scheduled_at", ["timestamp" => $incident->scheduled_at_diff]) : null }}
- - +
From 941809037aa484d28d17ccc49477311a7d9b07da Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 4 Sep 2015 11:33:14 +0100 Subject: [PATCH 2/3] Lock on laravel 5.1.12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ad6aa7cd..52d3d96b 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ ], "require": { "php": "^5.5.9", - "laravel/framework": "~5.1.10", + "laravel/framework": "5.1.12", "alt-three/emoji": "^1.2", "barryvdh/laravel-cors": "^0.5", "doctrine/dbal": "^2.5", From 1ac4b7a64a0514cc396141eac3ad117ed4f66d16 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 4 Sep 2015 11:45:44 +0100 Subject: [PATCH 3/3] Updated dependencies --- composer.lock | 78 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/composer.lock b/composer.lock index 26e161ed..211b8612 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8ad05f265a7f13a963a021a55b21f451", + "hash": "d3a5a772f42f777d459f40bf984bc3c9", "packages": [ { "name": "alt-three/emoji", @@ -305,16 +305,16 @@ }, { "name": "doctrine/annotations", - "version": "v1.2.6", + "version": "v1.2.7", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "f4a91702ca3cd2e568c3736aa031ed00c3752af4" + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/f4a91702ca3cd2e568c3736aa031ed00c3752af4", - "reference": "f4a91702ca3cd2e568c3736aa031ed00c3752af4", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", "shasum": "" }, "require": { @@ -369,20 +369,20 @@ "docblock", "parser" ], - "time": "2015-06-17 12:21:22" + "time": "2015-08-31 12:32:49" }, { "name": "doctrine/cache", - "version": "v1.4.1", + "version": "v1.4.2", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03" + "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/c9eadeb743ac6199f7eec423cb9426bc518b7b03", - "reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03", + "url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca", + "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca", "shasum": "" }, "require": { @@ -439,7 +439,7 @@ "cache", "caching" ], - "time": "2015-04-15 00:11:59" + "time": "2015-08-31 12:36:41" }, { "name": "doctrine/collections", @@ -509,16 +509,16 @@ }, { "name": "doctrine/common", - "version": "v2.5.0", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/doctrine/common.git", - "reference": "cd8daf2501e10c63dced7b8b9b905844316ae9d3" + "reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/cd8daf2501e10c63dced7b8b9b905844316ae9d3", - "reference": "cd8daf2501e10c63dced7b8b9b905844316ae9d3", + "url": "https://api.github.com/repos/doctrine/common/zipball/0009b8f0d4a917aabc971fb089eba80e872f83f9", + "reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9", "shasum": "" }, "require": { @@ -578,7 +578,7 @@ "persistence", "spl" ], - "time": "2015-04-02 19:55:44" + "time": "2015-08-31 13:00:22" }, { "name": "doctrine/dbal", @@ -1544,7 +1544,7 @@ "name": "Jeremy Lindblom", "email": "jeremeamia@gmail.com", "homepage": "https://github.com/jeremeamia", - "role": "developer" + "role": "Developer" } ], "description": "Serialize Closure objects, including their context and binding", @@ -1562,16 +1562,16 @@ }, { "name": "laravel/framework", - "version": "v5.1.10", + "version": "v5.1.12", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "d47ccc8de10ccb6f328cc90f901ca5e47e077c93" + "reference": "76a9816f37a58383f6ba093ccf08f253e5488555" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/d47ccc8de10ccb6f328cc90f901ca5e47e077c93", - "reference": "d47ccc8de10ccb6f328cc90f901ca5e47e077c93", + "url": "https://api.github.com/repos/laravel/framework/zipball/76a9816f37a58383f6ba093ccf08f253e5488555", + "reference": "76a9816f37a58383f6ba093ccf08f253e5488555", "shasum": "" }, "require": { @@ -1686,7 +1686,7 @@ "framework", "laravel" ], - "time": "2015-08-12 18:16:08" + "time": "2015-08-30 23:25:48" }, { "name": "league/commonmark", @@ -1893,16 +1893,16 @@ }, { "name": "monolog/monolog", - "version": "1.16.0", + "version": "1.17.1", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "c0c0b4bee3aabce7182876b0d912ef2595563db7" + "reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c0c0b4bee3aabce7182876b0d912ef2595563db7", - "reference": "c0c0b4bee3aabce7182876b0d912ef2595563db7", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/0524c87587ab85bc4c2d6f5b41253ccb930a5422", + "reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422", "shasum": "" }, "require": { @@ -1919,7 +1919,7 @@ "php-console/php-console": "^3.1.3", "phpunit/phpunit": "~4.5", "phpunit/phpunit-mock-objects": "2.3.0", - "raven/raven": "~0.8", + "raven/raven": "~0.11", "ruflin/elastica": ">=0.90 <3.0", "swiftmailer/swiftmailer": "~5.3", "videlalvaro/php-amqplib": "~2.4" @@ -1965,7 +1965,7 @@ "logging", "psr-3" ], - "time": "2015-08-09 17:44:44" + "time": "2015-08-31 09:17:37" }, { "name": "mtdowling/cron-expression", @@ -3791,16 +3791,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.8.4", + "version": "4.8.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "55bf1d6092b0e13a1f26bd5eaffeef3d8ad85ea7" + "reference": "2246830f4a1a551c67933e4171bf2126dc29d357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/55bf1d6092b0e13a1f26bd5eaffeef3d8ad85ea7", - "reference": "55bf1d6092b0e13a1f26bd5eaffeef3d8ad85ea7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2246830f4a1a551c67933e4171bf2126dc29d357", + "reference": "2246830f4a1a551c67933e4171bf2126dc29d357", "shasum": "" }, "require": { @@ -3859,24 +3859,24 @@ "testing", "xunit" ], - "time": "2015-08-15 04:21:23" + "time": "2015-08-24 04:09:38" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.6", + "version": "2.3.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42" + "reference": "5e2645ad49d196e020b85598d7c97e482725786a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/18dfbcb81d05e2296c0bcddd4db96cade75e6f42", - "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a", + "reference": "5e2645ad49d196e020b85598d7c97e482725786a", "shasum": "" }, "require": { - "doctrine/instantiator": "~1.0,>=1.0.2", + "doctrine/instantiator": "^1.0.2", "php": ">=5.3.3", "phpunit/php-text-template": "~1.2", "sebastian/exporter": "~1.2" @@ -3915,7 +3915,7 @@ "mock", "xunit" ], - "time": "2015-07-10 06:54:24" + "time": "2015-08-19 09:14:08" }, { "name": "sebastian/comparator",