mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- harmonize field types and use explicit names - store html value alongside markdown descriptions for better performance - add duration and bandwidth to podcast analytics - add new analytics table for podcast hits by hour - replace visible MAXMIND_LICENCE_KEY with variable
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class AddAnalyticsUnknownUseragentsProcedure
|
|
* Creates analytics_unknown_useragents procedure in database
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddAnalyticsUnknownUseragentsProcedure extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
// Creates Procedure for data insertion
|
|
// Example: CALL analytics_unknown_useragents('Podcasts/1430.46 CFNetwork/1125.2 Darwin/19.4.0');
|
|
$procedureName = $this->db->prefixTable('analytics_unknown_useragents');
|
|
$createQuery = <<<EOD
|
|
CREATE PROCEDURE `$procedureName` (IN `p_useragent` VARCHAR(191) CHARSET utf8mb4) MODIFIES SQL DATA
|
|
DETERMINISTIC
|
|
SQL SECURITY INVOKER
|
|
COMMENT 'Add an unknown useragent to table $procedureName.'
|
|
INSERT INTO `$procedureName`(`useragent`)
|
|
VALUES (p_useragent)
|
|
ON DUPLICATE KEY UPDATE `hits`=`hits`+1
|
|
EOD;
|
|
$this->db->query($createQuery);
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$procedureName = $this->db->prefixTable('analytics_unknown_useragents');
|
|
$this->db->query("DROP PROCEDURE IF EXISTS `$procedureName`");
|
|
}
|
|
}
|