summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus2024-01-16 02:28:48 +0100
committerhorus2024-01-16 02:28:48 +0100
commit0f94a6c78dc5d4563c7f10a43e93c80832d9bf71 (patch)
treedf95937170c3dd0ce30116d77abd5c65a93eac81
parent264302f6cdc630097e45ac76509da20ea4ccf684 (diff)
downloadcurious-0f94a6c78dc5d4563c7f10a43e93c80832d9bf71.tar.gz
stats!
-rw-r--r--app/Http/Controllers/IndexController.php10
-rw-r--r--resources/views/about.blade.php14
2 files changed, 23 insertions, 1 deletions
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
<br>
You can now also follow on Mastodon <a title="Follow on Mastodon {{ env('MASTODON_HANDLE') }}" href="{{ env('MASTODON_URL') }}" target=_blank>{!! file_get_contents(public_path() . "/img/mastodon.svg") !!} @MostDiscussed</a> to stay up to date.
+<h2>📈 Meanwhile: <strong>Stats!</strong></h2>
+
+Indexed articles: <strong>{{ $count_articles }}</strong>
+<br>
+Discussions on HN: <strong>{{ $count_discussions }} </strong>
+<br>
+Sum of all comments: <strong>{{ $count_comments}} </strong>
+<br>
+Sum of all upvotes: <strong>{{ $count_upvotes }} </strong> (...soo much internet juice 🤤)
+<br>
+<br>
+Keep reading!
+
+
<!--
I was curious what HN may find interesting, so I used upvoted or discussed articles from Wikipedia as a proxy and build this. All articles are <a href="{{ route('popular_topics') }}">structured and categorized</a> to get a better overview. Unsurprisingly <a href="{{ route('topic', 'computing') }}">computing</a> was on the top, but then it might get interesting.
<br>