function tripal_mviews_report

1.x mviews.inc tripal_mviews_report()

A template function to render a listing of all Materialized Views

Related topics

1 string reference to 'tripal_mviews_report'
tripal_core_menu in tripal_core/tripal_core.module
Implements hook_menu(). Defines all menu items needed by Tripal Core

File

tripal_core/includes/mviews.inc, line 81
Contains functions for viewing and editing of Materialized Views on a Tripal website.

Code

function tripal_mviews_report() {
  $header = array('', 'MView Name', 'Last Update', 'Status', 'Description', '');
  $rows = array();
  $mviews = db_query("SELECT * FROM {tripal_mviews} ORDER BY name");

  while ($mview = db_fetch_object($mviews)) {
    if ($mview->last_update > 0) {
      $update = format_date($mview->last_update);
    }
    else {
      $update = 'Not yet populated';
    }

    $rows[] = array(
      l(t('View'), "admin/tripal/mviews/report/$mview->mview_id") . " | " .
        l(t('Edit'), "admin/tripal/mviews/edit/$mview->mview_id") . " | " .
        l(t('Populate'), "admin/tripal/mviews/action/update/$mview->mview_id"),
      $mview->name,
      $update,
      $mview->status,
      $mview->comment,
      l(t('Delete'), "admin/tripal/mviews/action/delete/$mview->mview_id"),
    );
  }

  $rows[] = array(
    'data' => array(
      array('data' => l(t('Create a new materialized view.'), "admin/tripal/mviews/new"),
        'colspan' => 6),
    )
  );
  $page = '</p>' . t("Materialized Views (MViews) are custom tables populated with a defined SQL statement.  
    Because Chado is highly normalized and highly constrained it serves as a wonderful 
    data storage platform, but unfortunately some queries may be slow.  MViews alleviate slowness by aggregating data
    into tables that are more easy to query.  Use MViews to create tables for custom search pages or custom Tripal
    module development.") . '</p>';
  $page .= '<p><b>' . t("MViews behaves in the following way:") . '</b><ul>' .
    '<li>' . t("The SQL statement defined for an MVIEW will be used to populate the table") . '</li>' .
    '<li>' . t("Altering the table structure of an MView will cause the MView table to be dropped and recreated.  All records in the MView will be lost.") . '</li>' .
    '<li>' . t("Altering the query of an existing view will not change the MView table. No records will be lost. ") . '</li>' .
    '<li>' . t("Repopulating an MView that is already populated will result in replacement of all records.") . '</li>' .
    '<li>' . t("A database transaction will be used when populating MViews. Therefore replacement of records does not occur until the query completes.  Any search forms or pages dependent on the MView will continue to function.") . '</li>' .
    '</ul></p>';
  $page .= '<b>' . t("Existing MViews") . '</b>';
  $page .= theme('table', $header, $rows);
  return $page;
}