From f764488d010caa64a90a516b657941dc4bf6a467 Mon Sep 17 00:00:00 2001 From: Zach Baird <30800863+ZachBaird@users.noreply.github.com> Date: Mon, 14 Oct 2024 04:02:36 -0400 Subject: [PATCH] Feature: Adds active announcements tile to v2 admin dashboard. (#4833) ## Because This change adds a tile indicating active announcement count on the admin dashboard. This will allow admins to briefly see if there have been new announcements. Clicking on the tile will navigate the admin to the announcements page. ## This PR - Adds a `.active_count` scope on `announcement.rb`. It builds off of the existing `.active` scope. - The new scope is used in the admin/dashboardcontroller to populate `active_announcements_count`. - `active_announcements_count` is presented in the view as another tile similar to the unresolved flags tile. - The `announcement` model spec is updated to test for this new scope. ## Issue Closes #4619 ## Pull Request Requirements - [x] I have thoroughly read and understand [The Odin Project Contributing Guide](https://github.com/TheOdinProject/theodinproject/blob/main/CONTRIBUTING.md) - [x] The title of this PR follows the `keyword: brief description of change` format, using one of the following keywords: - `Feature` - adds new or amends existing user-facing behavior - `Chore` - changes that have no user-facing value, refactors, dependency bumps, etc - `Fix` - bug fixes - [x] The `Because` section summarizes the reason for this PR - [x] The `This PR` section has a bullet point list describing the changes in this PR - [x] I have verified all tests and linters pass after making these changes. - [x] If this PR addresses an open issue, it is linked in the `Issue` section - [x] If applicable, this PR includes new or updated automated tests --- app/controllers/admin/dashboard_controller.rb | 1 + app/views/admin/dashboard/show.html.erb | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index eb5dde722d..d13512fac7 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -2,6 +2,7 @@ module Admin class DashboardController < Admin::BaseController def show @active_flags_count = Flag.count_for(:active) + @active_announcements_count = Announcement.active.count end end end diff --git a/app/views/admin/dashboard/show.html.erb b/app/views/admin/dashboard/show.html.erb index 005d170ddc..e2c6648b7d 100644 --- a/app/views/admin/dashboard/show.html.erb +++ b/app/views/admin/dashboard/show.html.erb @@ -13,7 +13,12 @@