public function AcquiaLiftReport::renderStatsForOptionSet in Acquia Lift Connector 7
Implements PersonalizeAgentReportInterface::renderStatsForOptionSet().
File
- plugins/
agent_types/ AcquiaLiftAgent.inc, line 2151 - Provides an agent type for Acquia Lift
Class
- AcquiaLiftReport
- Responsible retrieving and generating reports on the Acquia Lift agent.
Code
public function renderStatsForOptionSet($option_set, $date_from, $date_to = NULL) {
$date_start = date('Y-m-d', $date_from);
if (empty($date_to)) {
$date_to = time();
}
$date_end = date('Y-m-d', $date_to);
$report_data = $this
->generateReportConfiguration(array(
'start' => $date_start,
'end' => $date_end,
));
if (!isset($report_data['confidence'])) {
$this
->loadConfidenceData($report_data);
if (isset($report_data['raw']['confidence']['error']) || !isset($report_data['raw']['confidence']['data'])) {
return array();
}
else {
$data = $this
->extractConfidenceReportData($report_data['raw']['confidence']['data']['items']);
}
}
$decisions = $goals = 0;
// Get a total count of all decisions made for this Option Set and all
// goals received.
foreach ($data['features'][self::NO_FEATURES] as $choice => $info) {
list($decision_name, $option_id) = explode(':', $choice);
if ($decision_name != $option_set->decision_name) {
continue;
}
$decisions += $info['decisions'];
$goals += $info['goals'];
}
$report[] = format_plural($decisions, '1 view', '@count views');
$report[] = format_plural($goals, '1 goal', '@count goals');
return $report;
}