CC-3131: Latency of stream authentication warning in Stream Settings page

- it compares boot time of liquidsoap and the time user clicks on "Save"
on stream setting page. The status only gets updated if the
"boot_time" > "user update time"
- as soon as a user click on save, status is set to "wating"
- since there is no timing issue, quering interval is reduced to 1 sec
This commit is contained in:
James 2011-11-29 20:15:38 -05:00
parent 85b8209db9
commit 9c65bfeba7
10 changed files with 71 additions and 29 deletions

View file

@ -573,6 +573,25 @@ class Application_Model_Preference
return $val;
}
}
/**
* Stores the last timestamp of user updating stream setting
*/
public static function SetStreamUpdateTimestamp() {
$now = time();
self::SetValue("stream_update_timestamp", $now);
}
/**
* Gets the last timestamp of user updating stream setting
*/
public static function GetStreamUpdateTimestemp() {
$update_time = self::GetValue("stream_update_timestamp");
if($update_time == null){
$update_time = 0;
}
return $update_time;
}
/* User specific preferences start */

View file

@ -113,22 +113,29 @@ class Application_Model_StreamSetting {
}
}
public static function setLiquidsoapError($stream_id, $msg){
/*
* Stores liquidsoap status if $boot_time > save time.
* save time is the time that user clicked save on stream setting page
*/
public static function setLiquidsoapError($stream_id, $msg, $boot_time=null){
global $CC_DBC;
$keyname = "s".$stream_id."_liquidsoap_error";
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
." WHERE keyname = '$keyname'";
$result = $CC_DBC->GetOne($sql);
if ($result == 1){
$sql = "UPDATE cc_stream_setting"
." SET value = '$msg'"
$update_time = Application_Model_Preference::GetStreamUpdateTimestemp();
if($boot_time == null || $boot_time > $update_time ){
$keyname = "s".$stream_id."_liquidsoap_error";
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
." WHERE keyname = '$keyname'";
}else{
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
." VALUES ('$keyname', '$msg', 'string')";
$result = $CC_DBC->GetOne($sql);
if ($result == 1){
$sql = "UPDATE cc_stream_setting"
." SET value = '$msg'"
." WHERE keyname = '$keyname'";
}else{
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
." VALUES ('$keyname', '$msg', 'string')";
}
$res = $CC_DBC->query($sql);
}
$res = $CC_DBC->query($sql);
}
public static function getLiquidsoapError($stream_id){