Skip to content

Commit

Permalink
Revert Issue #3298886 for 12.4.7 branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-getopensocial authored and ronaldtebrake committed Dec 2, 2024
1 parent e090093 commit d8a89fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
- {name: config.factory.override, priority: 10}
social_group.group_statistics:
class: Drupal\social_group\GroupStatistics
arguments: ['@database', '@entity_type.manager']
arguments: ['@database']
social_group.group_mute_notify:
class: Drupal\social_group\GroupMuteNotify
arguments: ['@flag', '@entity_type.manager']
Expand Down
26 changes: 8 additions & 18 deletions modules/social_features/social_group/src/GroupStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@ class GroupStatistics {
*/
protected $database;

/**
* The entity type manager interface.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;

/**
* Constructor for SocialGroupMembersCount.
*
* @param \Drupal\Core\Database\Connection $connection
* The database connection.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager interface.
*/
public function __construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager) {
public function __construct(Connection $connection) {
$this->database = $connection;
$this->entityTypeManager = $entity_type_manager;
}

/**
Expand Down Expand Up @@ -65,7 +55,7 @@ public function getGroupMemberCount(GroupInterface $group) {
* The number of nodes.
*/
public function getGroupNodeCount(GroupInterface $group, $type) {
return $this->count($group, 'group_node:' . $type);
return $this->count($group, 'group_node-' . $type);
}

/**
Expand All @@ -81,12 +71,12 @@ public function getGroupNodeCount(GroupInterface $group, $type) {
*/
protected function count(GroupInterface $group, $type) {
// Additional caching not required since views does this for us.
return $this->entityTypeManager->getStorage('group_content')->getQuery()
->accessCheck(FALSE)
->condition('gid', $group->id())
->condition('plugin_id', $type)
->count()
->execute();
$query = $this->database->select('group_relationship_field_data', 'gcfd');
$query->addField('gcfd', 'gid');
$query->condition('gcfd.gid', $group->id());
$query->condition('gcfd.type', $group->getGroupType()->id() . '-' . $type, 'LIKE');

return $query->countQuery()->execute()->fetchField();
}

}

0 comments on commit d8a89fc

Please sign in to comment.