File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,14 +7,18 @@ class Instance
77
88 def initialize ( resource )
99 @domain = resource . domain
10- @accounts_count = resource . accounts_count
10+ @accounts_count = resource . is_a? ( DomainBlock ) ? nil : resource . accounts_count
1111 @domain_block = resource . is_a? ( DomainBlock ) ? resource : DomainBlock . find_by ( domain : domain )
1212 end
1313
1414 def cached_sample_accounts
1515 Rails . cache . fetch ( "#{ cache_key } /sample_accounts" , expires_in : 12 . hours ) { Account . where ( domain : domain ) . searchable . joins ( :account_stat ) . popular . limit ( 3 ) }
1616 end
1717
18+ def cached_accounts_count
19+ @accounts_count || Rails . cache . fetch ( "#{ cache_key } /count" , expires_in : 12 . hours ) { Account . where ( domain : domain ) . count }
20+ end
21+
1822 def to_param
1923 domain
2024 end
Original file line number Diff line number Diff line change 3333 %h4
3434 = instance.domain
3535 %small
36- = t('admin.instances.known_accounts', count: instance.accounts_count )
36+ = t('admin.instances.known_accounts', count: instance.cached_accounts_count )
3737
3838 - if instance.domain_block
3939 - if !instance.domain_block.noop?
You can’t perform that action at this time.
0 commit comments