Skip to content
This repository was archived by the owner on Nov 2, 2022. It is now read-only.

getData

Gaelan Lloyd edited this page Sep 2, 2016 · 2 revisions

/functions/getData.php is responsible for collecting data from the database for a given metric and then passing it to writeReport().

Parameters

getData( $reportItem, $site, $sitesAsSeries, $useAlternateSiteNames );

Parameter Description
$reportItem The metric id to fetch data for.
$site (Optional) A comma-separated string (with no spaces between items) of sites to fetch data for. If not provided, data for all non-ignored sites will be returned.
$sitesAsSeries (Optional) Set this to TRUE if you want to transpose the sites and metric data. This will result in a chart showing a single metric with data series for each non-ignored site in your environment.
$useAlternateSiteNames (Optional) Set this to TRUE to return alt_name values for each site rather than the default name values.

Notes

  • getData() is almost always used immediately preceeding writeReport().
  • Store the output in a variable and then pass it to writeReport().

Example usage

Here's some example joint getData() and writeReport() operations:

// Get data for metric id 77 for site 1
// Customize the report title and add a caption
$reportData = getData( "77", "1" );
echo writeReport( $reportData, "Average response time", "How long it took operators to respond, on average, to incoming chats." );

// Get data for 5 items for site 1
// Customize the report title
$reportData = getData( "24,26,28,30,32", "1" );
echo writeReport( $reportData, "English site" );

// Get data for metric id 1, for all sites, transpose data, and use alternate site names
// Customize the report title and make it a hyperlink to report 1, and add a caption
$reportData = getData( "1", NULL, TRUE, TRUE );
echo writeReport( $reportData, "<a href=\"/?r=1\">Overall traffic</a>", "The total number of page views to each website.", TRUE );

Learn more

Clone this wiki locally