Skip to content

Commit 4fe7f21

Browse files
authored
Use async_count in more view locations (mastodon#32086)
1 parent 77f5b12 commit 4fe7f21

File tree

8 files changed

+8
-4
lines changed

8 files changed

+8
-4
lines changed

app/controllers/admin/announcements_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Admin::AnnouncementsController < Admin::BaseController
66

77
def index
88
authorize :announcement, :index?
9+
@published_announcements_count = Announcement.published.async_count
910
end
1011

1112
def new

app/controllers/admin/disputes/appeals_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Admin::Disputes::AppealsController < Admin::BaseController
66
def index
77
authorize :appeal, :index?
88

9+
@pending_appeals_count = Appeal.pending.async_count
910
@appeals = filtered_appeals.page(params[:page])
1011
end
1112

app/controllers/admin/trends/links/preview_card_providers_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Admin::Trends::Links::PreviewCardProvidersController < Admin::BaseControll
44
def index
55
authorize :preview_card_provider, :review?
66

7+
@pending_preview_card_providers_count = PreviewCardProvider.unreviewed.async_count
78
@preview_card_providers = filtered_preview_card_providers.page(params[:page])
89
@form = Trends::PreviewCardProviderBatch.new
910
end

app/controllers/admin/trends/tags_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Admin::Trends::TagsController < Admin::BaseController
44
def index
55
authorize :tag, :review?
66

7+
@pending_tags_count = Tag.pending_review.async_count
78
@tags = filtered_tags.page(params[:page])
89
@form = Trends::TagBatch.new
910
end

app/views/admin/announcements/index.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
%strong= t('admin.relays.status')
1010
%ul
1111
%li= filter_link_to t('generic.all'), published: nil, unpublished: nil
12-
%li= filter_link_to safe_join([t('admin.announcements.live'), "(#{number_with_delimiter(Announcement.published.count)})"], ' '), published: '1', unpublished: nil
12+
%li= filter_link_to safe_join([t('admin.announcements.live'), "(#{number_with_delimiter(@published_announcements_count.value)})"], ' '), published: '1', unpublished: nil
1313

1414
- if @announcements.empty?
1515
.muted-hint.center-text

app/views/admin/disputes/appeals/index.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
.filter-subset
66
%strong= t('admin.tags.review')
77
%ul
8-
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{Appeal.pending.count})"], ' '), status: 'pending'
8+
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{@pending_appeals_count.value})"], ' '), status: 'pending'
99
%li= filter_link_to t('admin.trends.approved'), status: 'approved'
1010
%li= filter_link_to t('admin.trends.rejected'), status: 'rejected'
1111

app/views/admin/trends/links/preview_card_providers/index.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
%li= filter_link_to t('generic.all'), status: nil
1313
%li= filter_link_to t('admin.trends.approved'), status: 'approved'
1414
%li= filter_link_to t('admin.trends.rejected'), status: 'rejected'
15-
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{PreviewCardProvider.unreviewed.count})"], ' '), status: 'pending_review'
15+
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{@pending_preview_card_providers_count.value})"], ' '), status: 'pending_review'
1616
.back-link
1717
= link_to admin_trends_links_path do
1818
= material_symbol 'chevron_left'

app/views/admin/trends/tags/index.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
%li= filter_link_to t('generic.all'), status: nil
1313
%li= filter_link_to t('admin.trends.approved'), status: 'approved'
1414
%li= filter_link_to t('admin.trends.rejected'), status: 'rejected'
15-
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{Tag.pending_review.count})"], ' '), status: 'pending_review'
15+
%li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{@pending_tags_count.value})"], ' '), status: 'pending_review'
1616

1717
= form_with model: @form, url: batch_admin_trends_tags_path do |f|
1818
= hidden_field_tag :page, params[:page] || 1

0 commit comments

Comments
 (0)