From 0f94a6c78dc5d4563c7f10a43e93c80832d9bf71 Mon Sep 17 00:00:00 2001 From: horus Date: Tue, 16 Jan 2024 02:28:48 +0100 Subject: stats! --- app/Http/Controllers/IndexController.php | 10 +++++++++- resources/views/about.blade.php | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 824a2e2..f24d1ad 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -19,7 +19,15 @@ class IndexController extends Controller public function about() { - return view('about'); + $count_articles = DB::Select("SELECT COUNT(*) as count FROM article;")[0]; + $count_discussions = DB::Select("SELECT COUNT(*) as count FROM discussion;")[0]; + $count_comments = DB::Select("SELECT sum(comments) as count FROM discussion;")[0]; + $count_upvotes = DB::Select("SELECT sum(upvotes) as count FROM discussion;")[0]; + return view('about', [ + "count_articles" => $count_articles->count, + "count_discussions" => $count_discussions->count, + "count_comments" => number_format($count_comments->count), + "count_upvotes" => number_format($count_upvotes->count)]); } public function topic( $topic ) diff --git a/resources/views/about.blade.php b/resources/views/about.blade.php index b8547f2..dd1d848 100644 --- a/resources/views/about.blade.php +++ b/resources/views/about.blade.php @@ -41,6 +41,20 @@ If you have feedback, want to report a bug or just say hello, hit me up by e-mai
You can now also follow on Mastodon {!! file_get_contents(public_path() . "/img/mastodon.svg") !!} @MostDiscussed to stay up to date. +

📈 Meanwhile: Stats!

+ +Indexed articles: {{ $count_articles }} +
+Discussions on HN: {{ $count_discussions }} +
+Sum of all comments: {{ $count_comments}} +
+Sum of all upvotes: {{ $count_upvotes }} (...soo much internet juice 🤤) +
+
+Keep reading! + +