Skip to content
Snippets Groups Projects

Unbungle sponsored events counting

Merged Brendan Blaine requested to merge owner-tools-event-count-refine into 7.x-3.x
1 unresolved thread
@@ -1174,9 +1174,12 @@ function drupalorg_org_owner_tools(stdClass $node) {
}
// Events sponsored.
$view = views_get_view('community_events');
$view_preview = $view->preview('block_sponsored_by_org', [$node->nid]);
$events_sponsored_count = count($view->result);
$one_year_ago = (new DateTimeImmutable('-1 year'))->format('c');
$query = new EntityFieldQuery();
$events_sponsored_count = $query->fieldCondition('field_event_sponsors', 'target_id', $node->nid)
->fieldCondition('field_date_of_event', 'value', $one_year_ago, '>=')
->count()
->execute();
// Supported projects.
$view = views_get_view('drupalorg_organization_supported_projects');
@@ -1392,10 +1395,9 @@ function drupalorg_org_owner_tools(stdClass $node) {
$events_sponsored_credits = empty($node->field_drupalorg_rank_components[LANGUAGE_NONE][10]['value']) ? 0 : $node->field_drupalorg_rank_components[LANGUAGE_NONE][10]['value'];
$content['drupalorg_organization_sponsored_events'] = [
'#markup' => '<div class="partner-tier-content"><div>' .
format_plural(
$supported_contributor_role_count,
'<strong>@count </strong> sponsored Drupal event',
'<strong>@count </strong> sponsored Drupal events'
format_plural($events_sponsored_count,
'<strong>@count </strong> sponsored Drupal event in the past year',
'<strong>@count </strong> sponsored Drupal events in the past year'
)
. '<br>' . t('<strong>→ @events_sponsored_credits weighted credits</strong>', [
'@events_sponsored_credits' => $events_sponsored_credits,
Loading