podcast_publisher-1.0.0-alpha3/modules/podcast_publisher_analytics/podcast_publisher_analytics.install

modules/podcast_publisher_analytics/podcast_publisher_analytics.install
<?php

/**
 * @file
 * Install hooks for module.
 */

/**
 * Implements hook_requirements().
 */
function podcast_publisher_analytics_requirements($phase) {
  $requirements = [];

  // Geolite city database must be in place in order
  // for the module to function properly.
  if ($phase == 'install' && !is_file(\Drupal::root() . '/libraries/geolite2/GeoLite2-City.mmdb')) {
    $requirements = [
      'podcast_publisher_analytics.geolite2' => [
        'title' => t('Geolite2 City Database'),
        'value' => t('None'),
        'description' => t('GeoLite2 City Database must be downloaded to the libraries folder. Check out the documentation at https://podcastpublisher.org for more information!'),
        'severity' => REQUIREMENT_ERROR,
      ],
    ];
  }

  return $requirements;
}

/**
 * Implements hook_schema().
 */
function podcast_publisher_analytics_schema() {
  return [
    'podcast_download_intent' => [
      'description' => 'Download Intents',
      'fields' => [
        'id' => [
          'type' => 'serial',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
        'requester_id' => [
          'type' => 'varchar',
          'not null' => TRUE,
          'length' => 255,
          'description' => 'The ID of the requester.',
        ],
        'user_agent_string' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => 'The raw user agent string.',
        ],
        'user_agent' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'description' => 'The referenced User Agent.',
        ],
        'source' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => "The request's source",
        ],
        'episode' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'description' => 'ID of referenced podcast episode.',
        ],
        'file' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'description' => 'ID of referenced audio file.',
        ],
        'geo_area' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'description' => "ID of requester's geo area.",
        ],
        'lat' => [
          'type' => 'float',
          'description' => 'The latitude of the requester.',
        ],
        'lng' => [
          'type' => 'float',
          'description' => 'The longitude of the requester.',
        ],
        'timestamp' => [
          'type' => 'int',
          'description' => 'The timestamp of the file request.',
        ],
        'httprange' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => "HTTP Header's range of bytes that were requested.",
        ],
        'processed' => [
          'type' => 'int',
          'size' => 'tiny',
          'description' => 'Indicator whether requester ID was already processed to be anonymous.',
        ],
        'original_intent' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'description' => 'This references the first call of given requester in given time frame.',
        ],
      ],
      'primary key' => ['id'],
      'foreign keys' => [
        'user_agent' => [
          'table' => 'podcast_user_agent',
          'columns' => [
            'id' => 'id',
          ],
        ],
        'episode' => [
          'table' => 'podcast_episode',
          'columns' => [
            'id' => 'id',
          ],
        ],
        'file' => [
          'table' => 'file_managed',
          'columns' => [
            'id' => 'id',
          ],
        ],
        'geo_area' => [
          'table' => 'podcast_geo_area',
          'columns' => [
            'id' => 'id',
          ],
        ],
        'original_intent' => [
          'table' => 'podcast_download_intent',
          'columns' => [
            'id' => 'id',
          ],
        ],
      ],
    ],
    'podcast_user_agent' => [
      'description' => 'User Agents',
      'fields' => [
        'id' => [
          'type' => 'serial',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
        'user_agent' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => 'The raw user agent string.',
        ],
        'bot' => [
          'type' => 'int',
          'size' => 'tiny',
          'description' => 'Indicator whether the user agent should be treated as a bot.',
        ],
        'client_name' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => 'The name of the client that requested the file.',
        ],
        'os_name' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => 'The name of the operating system the requester used.',
        ],
      ],
      'primary key' => ['id'],
    ],
    'podcast_geo_area' => [
      'description' => 'Geo Area',
      'fields' => [
        'id' => [
          'type' => 'serial',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
        'name' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => 'The name of the area.',
        ],
        'parent' => [
          'type' => 'int',
          'unsigned' => TRUE,
          'description' => 'Reference to the parent geo area.',
        ],
        'code' => [
          'type' => 'varchar',
          'length' => 20,
          'description' => "The area's code.",
        ],
        'area_type' => [
          'type' => 'varchar',
          'length' => 255,
          'description' => "The area's type.",
        ],
      ],
      'primary key' => ['id'],
      'foreign keys' => [
        'parent' => [
          'table' => 'podcast_geo_area',
          'columns' => [
            'id' => 'id',
          ],
        ],
      ],
    ],
  ];
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc