Class AnemometerModel

Description

class AnemometerModel

handle getting values from the conf file such as datasources and selecting and updating queries from the query_review table

  • author: Gavin Towey <gavin@box.com> and Geoff Anderson <geoff@box.com>
  • license: please

Located in /AnemometerModel.php (line 16)


	
			
Method Summary
AnemometerModel __construct (array $conf)
boolean checksum_exists (string $checksum)
string get_create_table (string $query)
mixed get_data_source (string $name)
mixed get_explain_for_sample (array $sample)
array get_form_fields (string $name)
string get_query_advisor (string $query)
mixed get_query_by_checksum (string $checksum)
MySQLi_Result get_query_samples (string $checksum, [int $limit = 1], [int $offset = 0])
array get_report (string $name)
array get_report_defaults ([string $type = 'report_defaults'])
array get_reviewers ()
array get_review_types ()
string get_table_status (string $query)
string get_visual_explain (string $explain_plan)
void init_query_explainer (array $sample)
void set_data_source (string $name)
void set_tables (string $fact, string $dimension)
void update_query (string $checksum, array $fields)
Methods
Constructor __construct (line 29)

Constructor. Initialize the model object

AnemometerModel __construct (array $conf)
  • array $conf: The global config information
checksum_exists (line 149)

Query the database and return true if a given checksum exists

  • return: true if it exists, otherwise false
  • access: public
boolean checksum_exists (string $checksum)
  • string $checksum: The checksum to check
connect_to_datasource (line 215)

Try to connect to the datasource, throw an exception on failure

  • throws: Exception
  • access: public
void connect_to_datasource ()
get_create_table (line 317)

Get the create table definitions for the query

  • return: The create table statements
  • access: public
string get_create_table (string $query)
  • string $query: the query to process
get_data_source (line 78)

Given a data source name, get the properties for it.

  • return: array of properties, or null if the datasource doesn't exist
  • access: public
mixed get_data_source (string $name)
  • string $name: The datasource name
get_data_source_names (line 65)

Get the list of names for the configured data sources

  • return: List of strings that describe the data sources
  • access: public
array get_data_source_names ()
get_default_report_action (line 37)

return the default report action name; usually either report or graph_search

  • return: the action name
  • access: public
string get_default_report_action ()
get_explain_for_sample (line 240)

try to get the explain plan for a query

  • return: Either a string with the explain plan, an error message or null
  • access: public
mixed get_explain_for_sample (array $sample)
  • array $sample: The query sample row data
get_form_fields (line 120)

get the field names for the given report

  • return: the table alias and field names
  • access: public
array get_form_fields (string $name)
  • string $name: The report name
get_query_advisor (line 300)

invoke pt-query-advisor and get its output

  • return: The script output
  • access: public
string get_query_advisor (string $query)
  • string $query: The query to feed the script
get_query_by_checksum (line 189)

given a checksum, return the full database row from the fact table for it.

  • return: The row of data, or null
  • access: public
mixed get_query_by_checksum (string $checksum)
  • string $checksum: The checksum to retrieve
get_query_samples (line 206)

Retrieve query samples from the history table, ordered from most recent

  • return: The result handle
  • access: public
MySQLi_Result get_query_samples (string $checksum, [int $limit = 1], [int $offset = 0])
  • string $checksum: The checksum to look up
  • int $limit: The number of sample to get (default 1)
  • int $offset: The starting record number
get_report (line 130)

get the full config information for the given report.

  • return: The configuration information
  • access: public
array get_report (string $name)
  • string $name: The report name
get_report_defaults (line 47)

get the default search values for the specified report type

  • return: The default values for the search form
  • access: public
array get_report_defaults ([string $type = 'report_defaults'])
  • string $type: The name of the report type
get_reviewers (line 139)

Return a list of reviewers defined by the config file

  • return: The list of reviewers
  • access: public
array get_reviewers ()
get_review_types (line 57)

return the list of review types. This is a configurable list of short text statuses that can describe the query.

  • return: the list of review status types
  • access: public
array get_review_types ()
get_table_status (line 334)

Get the table status info for the given query

  • return: The table status info
  • access: public
string get_table_status (string $query)
  • string $query: The query to process
get_visual_explain (line 283)

invoke pt-visual-explain and get its output

  • return: The visual explain output
  • access: public
string get_visual_explain (string $explain_plan)
  • string $explain_plan: The explain plan to feed the script
init_query_explainer (line 230)

Create a new query explainer object for the given query sample

  • access: public
void init_query_explainer (array $sample)
  • array $sample: The qeury sample
set_data_source (line 90)

sets the currently active datasource.

  • access: public
void set_data_source (string $name)
  • string $name: The name of the datasource
set_tables (line 109)

set the current fact and dimension table. That is the query_review and query_review_history tables. This is used when we select samples or update a query by its checksum.

  • access: public
void set_tables (string $fact, string $dimension)
  • string $fact: The name of the fact table
  • string $dimension: The name of the dimension table
update_query (line 164)

Preform an update query on the given checksum

  • access: public
void update_query (string $checksum, array $fields)
  • string $checksum: The checksum to update
  • array $fields: Array of Key => Value pairs to update

Documentation generated on Mon, 12 Mar 2012 11:59:41 -0700 by phpDocumentor 1.4.4