Skip to content
Snippets Groups Projects
Unverified Commit d7726854 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(analytics): set duration field to precise decimal as episode's audio file duration

parent 714d6b5d
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,10 @@ class AddAnalyticsPodcasts extends Migration ...@@ -27,7 +27,10 @@ class AddAnalyticsPodcasts extends Migration
'type' => 'DATE', 'type' => 'DATE',
], ],
'duration' => [ 'duration' => [
'type' => 'INT', // a hit in analytics podcast increments this value when a podcast is listened to in a given date.
// Here, the "cumulative listening time" on a podcast per day
// cannot surpass 999,999,999,999.999 seconds (~277,777,777 hours) - should be enough.
'type' => 'DECIMAL(15,3)',
'unsigned' => true, 'unsigned' => true,
], ],
'bandwidth' => [ 'bandwidth' => [
......
...@@ -36,7 +36,7 @@ class AddAnalyticsPodcastsProcedure extends Migration ...@@ -36,7 +36,7 @@ class AddAnalyticsPodcastsProcedure extends Migration
IN `p_os` VARCHAR(32), IN `p_os` VARCHAR(32),
IN `p_bot` TINYINT(1) UNSIGNED, IN `p_bot` TINYINT(1) UNSIGNED,
IN `p_filesize` INT UNSIGNED, IN `p_filesize` INT UNSIGNED,
IN `p_duration` INT UNSIGNED, IN `p_duration` DECIMAL(8,3) UNSIGNED,
IN `p_age` INT UNSIGNED, IN `p_age` INT UNSIGNED,
IN `p_new_listener` TINYINT(1) UNSIGNED IN `p_new_listener` TINYINT(1) UNSIGNED
) MODIFIES SQL DATA ) MODIFIES SQL DATA
......
...@@ -17,7 +17,7 @@ use CodeIgniter\Entity\Entity; ...@@ -17,7 +17,7 @@ use CodeIgniter\Entity\Entity;
/** /**
* @property int $podcast_id * @property int $podcast_id
* @property Time $date * @property Time $date
* @property int $duration * @property double $duration
* @property int $bandwidth * @property int $bandwidth
* @property int $unique_listeners * @property int $unique_listeners
* @property int $hits * @property int $hits
...@@ -36,7 +36,7 @@ class AnalyticsPodcasts extends Entity ...@@ -36,7 +36,7 @@ class AnalyticsPodcasts extends Entity
*/ */
protected $casts = [ protected $casts = [
'podcast_id' => 'integer', 'podcast_id' => 'integer',
'duration' => 'integer', 'duration' => 'double',
'bandwidth' => 'integer', 'bandwidth' => 'integer',
'unique_listeners' => 'integer', 'unique_listeners' => 'integer',
'hits' => 'integer', 'hits' => 'integer',
......
...@@ -252,7 +252,7 @@ if (! function_exists('podcast_hit')) { ...@@ -252,7 +252,7 @@ if (! function_exists('podcast_hit')) {
* @param integer $episodeId The Episode ID * @param integer $episodeId The Episode ID
* @param integer $bytesThreshold The minimum total number of bytes that must be downloaded so that an episode is counted (>1mn) * @param integer $bytesThreshold The minimum total number of bytes that must be downloaded so that an episode is counted (>1mn)
* @param integer $fileSize The podcast complete file size * @param integer $fileSize The podcast complete file size
* @param integer $duration The episode duration in seconds * @param double $duration The episode duration in seconds
* @param int $publicationTime The episode's publication time as a UNIX timestamp * @param int $publicationTime The episode's publication time as a UNIX timestamp
* @param string $serviceName The name of the service that had fetched the RSS feed * @param string $serviceName The name of the service that had fetched the RSS feed
*/ */
...@@ -261,7 +261,7 @@ if (! function_exists('podcast_hit')) { ...@@ -261,7 +261,7 @@ if (! function_exists('podcast_hit')) {
int $episodeId, int $episodeId,
int $bytesThreshold, int $bytesThreshold,
int $fileSize, int $fileSize,
int $duration, float $duration,
int $publicationTime, int $publicationTime,
string $serviceName string $serviceName
): void { ): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment