compucorp / uk.co.compucorp.civicrm.pivotreport

CiviCRM Pivot table reporting solution
Other
8 stars 13 forks source link

GSSPRT-137: Filter Prospects Without Client #137

Closed lisandro-compucorp closed 3 years ago

lisandro-compucorp commented 3 years ago

Overview

This PR solves an issue related to Prospect reports, that occurred when one or more prospects had no contact associated.

Before

All the prospects without contact were presented in one row:

Screen Shot 2021-07-26 at 21 08 36

In this screenshot, we can see the prospect with IDs 2790 and 2791 mixed in the same row, with 25 random contacts appearing on the contact column. There are 25 because of the default limit on the API call.

After

The prospects without contacts are not displayed.

Screen Shot 2021-07-26 at 20 53 48

Technical Details

This chained API call inside the Prospect.get is causing the problem:

'api.Contact.get' => array('id' => '$value.client_id', 'return' => array('id', 'contact_type', 'contact_sub_type', 'display_name')),

because $value.client_id is null on the Case data. For solving this, we should filter by Cases having client:

      'client_id' => ['IS NOT NULL' => 1],

Also, the getCount method was modified, since it should return all the matching results on the same query.