You are here

search_api_stats.install in Search API Stats 7

Same filename and directory in other branches
  1. 8 search_api_stats.install

Install, update and uninstall functions for the search_api_stats module.

File

search_api_stats.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the search_api_stats module.
 *
 */

/**
 * Implements hook_install().
 */
function search_api_stats_install() {
}

/**
 * Implements hook_uninstall().
 */
function search_api_stats_uninstall() {
}

/**
 * Implements hook_enable().
 */
function search_api_stats_enable() {
}

/**
 * Implements hook_schema().
 */
function search_api_stats_schema() {
  $schema['search_api_stats'] = array(
    'description' => 'Table that contains a log of Search API queries and performance.',
    'fields' => array(
      'qid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique log ID.',
      ),
      's_name' => array(
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'description' => 'Search API server machine_name',
      ),
      'i_name' => array(
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'description' => 'Search API index machine_name',
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp of when query occurred.',
      ),
      'numfound' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Number of results.',
      ),
      'total_time' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Total query time (miliseconds).',
      ),
      'prepare_time' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Time taken by Search API prepare phase for this query (miliseconds).',
      ),
      'process_time' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Time taken by Search API process phase for this query (miliseconds).',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid of the user who triggered the query.',
      ),
      'sid' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Session ID of user who triggered the query.',
      ),
      'showed_suggestions' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Indicates whether a spelling suggestion was shown.',
      ),
      'page' => array(
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Current results page.',
      ),
      'keywords' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
        'default' => '',
        'description' => 'Query keywords arguments.',
      ),
      'filters' => array(
        'type' => 'text',
        'size' => 'normal',
        'not null' => TRUE,
        'description' => 'Query filter arguments.',
      ),
      'sort' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'description' => 'Query sort arguments.',
      ),
      'language' => array(
        'description' => 'The site languages of keywords when search was executed.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'qid',
    ),
  );
  return $schema;
}

/**
 * Update 7001: Add language field in table:search_api_stats.
 * See https://drupal.org/node/1930930
 */
function search_api_stats_update_7102() {
  if (!db_field_exists('search_api_stats', 'language')) {
    $lang = array(
      'description' => 'The site languages of keywords when search was executed.',
      'type' => 'varchar',
      'length' => 12,
      'not null' => TRUE,
      'default' => '',
    );
    db_add_field('search_api_stats', 'language', $lang);
    return t('Added language field in search_api_stats table.');
  }
}

Functions

Namesort descending Description
search_api_stats_enable Implements hook_enable().
search_api_stats_install Implements hook_install().
search_api_stats_schema Implements hook_schema().
search_api_stats_uninstall Implements hook_uninstall().
search_api_stats_update_7102 Update 7001: Add language field in table:search_api_stats. See https://drupal.org/node/1930930