Removing bandwidth tracking
This commit is contained in:
parent
99d4f27320
commit
7608b9b298
|
@ -331,39 +331,6 @@ class StationPodcastTask implements AirtimeTask {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: this and the above StationPodcastTask should probably be unified since the
|
||||
* behaviour is essentially identical
|
||||
*
|
||||
* Class BandwidthLimitTask
|
||||
*
|
||||
* Checks the bandwidth limit rollover timer and resets the allotted
|
||||
* limit if enough time has passed (default: 1 month)
|
||||
*/
|
||||
class BandwidthLimitTask implements AirtimeTask {
|
||||
|
||||
const BANDWIDTH_LIMIT_RESET_TIMER_SECONDS = 2.628e+6;
|
||||
|
||||
/**
|
||||
* Check whether the task should be run
|
||||
*
|
||||
* @return bool true if the task needs to be run, otherwise false
|
||||
*/
|
||||
public function shouldBeRun() {
|
||||
$lastReset = Application_Model_Preference::getBandwidthLimitResetTimer();
|
||||
return empty($lastReset) || (microtime(true) > ($lastReset + self::BANDWIDTH_LIMIT_RESET_TIMER_SECONDS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task
|
||||
*/
|
||||
public function run() {
|
||||
Application_Model_Preference::resetStationPodcastDownloadCounter();
|
||||
Application_Model_Preference::setBandwidthLimitResetTimer(microtime(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class TaskFactory Factory class to abstract task instantiation
|
||||
*/
|
||||
|
|
|
@ -1573,68 +1573,6 @@ class Application_Model_Preference
|
|||
self::setValue("station_podcast_privacy", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors for station bandwidth limit.
|
||||
*/
|
||||
public static function getBandwidthLimit() {
|
||||
return self::getValue("bandwidth_limit");
|
||||
}
|
||||
|
||||
public static function setBandwidthLimit($value) {
|
||||
self::setValue("bandwidth_limit", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors for bandwidth limit counter.
|
||||
* Tracks bandwidth usage.
|
||||
*
|
||||
* @see ApiController::bandwidthUsageAction()
|
||||
* @see BandwidthLimitTask
|
||||
*/
|
||||
|
||||
public static function getBandwidthLimitCounter() {
|
||||
return self::getValue("bandwidth_limit_counter");
|
||||
}
|
||||
|
||||
public static function incrementBandwidthLimitCounter($value) {
|
||||
$counter = intval(self::getValue("bandwidth_limit_counter"));
|
||||
self::setValue("bandwidth_limit_counter", $counter + intval($value));
|
||||
}
|
||||
|
||||
public static function resetBandwidthLimitCounter() {
|
||||
self::setValue("bandwidth_limit_counter", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors for bandwidth limit reset timer.
|
||||
* Used to determine when to reset the bandwidth counter for the station.
|
||||
*
|
||||
* @see BandwidthLimitTask
|
||||
*/
|
||||
|
||||
public static function getBandwidthLimitResetTimer() {
|
||||
return self::getValue("bandwidth_limit_reset_timer");
|
||||
}
|
||||
|
||||
public static function setBandwidthLimitResetTimer($value) {
|
||||
self::setValue("bandwidth_limit_reset_timer", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors for bandwidth limit update timer.
|
||||
* Used to determine when the bandwidth was last updated for this station.
|
||||
*
|
||||
* @see ApiController::bandwidthUsageAction()
|
||||
*/
|
||||
|
||||
public static function getBandwidthLimitUpdateTimer() {
|
||||
return self::getValue("bandwidth_limit_update_timer");
|
||||
}
|
||||
|
||||
public static function setBandwidthLimitUpdateTimer() {
|
||||
self::setValue("bandwidth_limit_update_timer", microtime(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for CORS URLs
|
||||
*
|
||||
|
|
|
@ -15,17 +15,4 @@
|
|||
</fieldset>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
<?php $bandwidthLimit = Application_Model_Preference::getBandwidthLimit(); ?>
|
||||
<?php if ($bandwidthLimit): ?>
|
||||
<?php $bandwidthUsage = Application_Model_Preference::getBandwidthLimitCounter(); ?>
|
||||
<?php $percentInUse = sprintf("%01.1f%% ", $bandwidthUsage/$bandwidthLimit*100); ?>
|
||||
<div id="bandwidth_usage">
|
||||
<div style="padding-bottom: 2px;"><?php echo _("Monthly Listener Bandwidth Usage") ?></div>
|
||||
<div class="bandwidth_usage_progress_bar"></div>
|
||||
<div class="bandwidth_usage_percent_in_use"><?php echo $percentInUse . _("in use") ?></div>
|
||||
<div class="bandwidth_usage_used" style="width:<?php echo sprintf("%01.1f%%", min(100, $bandwidthUsage/$bandwidthLimit*100)) ?>;"></div>
|
||||
|
||||
<div style="margin-top: 17px; font-size: 12px;"><?php echo sprintf("%01.1fGB of %01.1fGB", $bandwidthUsage/pow(2, 30), $bandwidthLimit/pow(2, 30)); ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue