Skip to content

Commit

Permalink
Use new filter condition after CPS migration #DRUPS-25
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamás NAGY committed Apr 19, 2018
1 parent 789191a commit 5f141f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Apigee/ManagementAPI/DeveloperAppAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ public function getAllEnvironments()
/**
* After ensuring params are valid, fetches analytics data.
*
* @param string $devIdOrCompanyName
* @param string $devEmailOrCompany
* The ID of the developer or company name that owns the app. If you
* do not pass in this parameter you will get analytics for any app
* in the org with this app name, since app name is not unique across
* developers.
* @param bool $is_company
* If TRUE get app for company, otherwise for developer.
* @param string $appName
* The name of the app.
* @param string $metric
Expand Down Expand Up @@ -155,17 +157,18 @@ public function getAllEnvironments()
*
* @return array
*/
public function getByAppName($devIdOrCompanyName, $appName, $metric, $tStart, $tEnd, $tUnit, $sortBy, $sortOrder = 'ASC')
public function getByAppName($devEmailOrCompany, $is_company, $appName, $metric, $tStart, $tEnd, $tUnit, $sortBy, $sortOrder = 'ASC')
{
$params = self::validateParameters($metric, $tStart, $tEnd, $tUnit, $sortBy, $sortOrder);

// We need to filter analytics by the developer or company name. If we do not
// we will get back data for all apps with the app name, since they are not
// unique. For example, two developers can make an app named "test".
if (!empty($devIdOrCompanyName)) {
$org = $this->config->orgName;
$params['filter'] = "(developer eq '$org@@@$devIdOrCompanyName')";
if (!empty($devEmailOrCompany)) {
$filter_property = $is_company ? 'developer' : 'developer_email';
$params['filter'] = "({$filter_property} eq '{$devEmailOrCompany}')";
}

$params['developer_app'] = $appName;

$url = 'apps?';
Expand Down

0 comments on commit 5f141f3

Please sign in to comment.