From ccc4817d4d7ed8a9e650a4222fbf9fde7b71cc20 Mon Sep 17 00:00:00 2001 From: Luis Miguel Date: Wed, 29 Jan 2020 08:50:26 +0100 Subject: [PATCH 1/3] Improve ordering by activity date Some activity logs can occur at the same second, so ordering just by date can show the results unordered. As per @lcharette suggestion, we can order by `occurred_at` AND `id`. That should gives better results. --- .../admin/src/Sprunje/ActivitySprunje.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php b/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php index 9c5e03819..ece0a4044 100644 --- a/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php +++ b/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php @@ -83,4 +83,20 @@ protected function sortUser($query, $direction) return $this; } + + /** + * Sort based on activity occurred_at. + * + * @param Builder $query + * @param string $direction + * + * @return self + */ + protected function sortOccurredAt($query, $direction) + { + $query->orderBy('activities.occurred_at', $direction) + ->orderby('activities.id', $direction); + + return $this; + } } From 9e9b95c26d01ad1f24012cb8e012734391b7649f Mon Sep 17 00:00:00 2001 From: Luis Miguel Date: Wed, 29 Jan 2020 19:21:35 +0100 Subject: [PATCH 2/3] Update ActivitySprunje.php --- app/sprinkles/admin/src/Sprunje/ActivitySprunje.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php b/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php index ece0a4044..575564937 100644 --- a/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php +++ b/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php @@ -68,7 +68,7 @@ protected function filterUser($query, $value) return $this; } - + /** * Sort based on user last name. * From 7b91894cf74cff22cf1a686ef4413482e13cc825 Mon Sep 17 00:00:00 2001 From: Luis Miguel Date: Thu, 30 Jan 2020 15:27:46 +0100 Subject: [PATCH 3/3] Remove whitespaces --- app/sprinkles/admin/src/Sprunje/ActivitySprunje.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php b/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php index 575564937..698ef7a4d 100644 --- a/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php +++ b/app/sprinkles/admin/src/Sprunje/ActivitySprunje.php @@ -68,7 +68,7 @@ protected function filterUser($query, $value) return $this; } - + /** * Sort based on user last name. * @@ -83,7 +83,7 @@ protected function sortUser($query, $direction) return $this; } - + /** * Sort based on activity occurred_at. *