mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 16:44:11 +03:00
Fix bug with user wait time
This commit is contained in:
parent
092e9c2dcf
commit
9037f69c09
@ -298,7 +298,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
|
||||
$thread = Thread::create();
|
||||
|
||||
// Update thread values
|
||||
$thread->lastRevision = $last_revision = 10;
|
||||
$thread->state = $state = Thread::STATE_CHATTING;
|
||||
$thread->lastToken = $last_token = 11;
|
||||
|
||||
@ -309,7 +308,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
|
||||
$thread->messageCount = $message_count = 15;
|
||||
|
||||
$thread->created = $created = time() - 200;
|
||||
$thread->modified = $modified = time() - 190;
|
||||
$thread->chatStarted = $chat_started = time() - 180;
|
||||
|
||||
$thread->agentId = $agent_id = 16;
|
||||
@ -336,7 +334,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
|
||||
$thread_info = $this->_helper_getThreadInfo($thread->id);
|
||||
|
||||
// Check values
|
||||
$this->assertEquals($thread_info['lrevision'],$last_revision);
|
||||
$this->assertEquals($thread_info['istate'], $state);
|
||||
$this->assertEquals($thread_info['ltoken'], $last_token);
|
||||
|
||||
@ -347,7 +344,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals($thread_info['messageCount'], $message_count);
|
||||
|
||||
$this->assertEquals($thread_info['dtmcreated'], $created);
|
||||
$this->assertEquals($thread_info['dtmmodified'], $modified);
|
||||
$this->assertEquals($thread_info['dtmchatstarted'], $chat_started);
|
||||
|
||||
$this->assertEquals($thread_info['agentId'], $agent_id);
|
||||
|
@ -526,28 +526,31 @@ Class Thread {
|
||||
}
|
||||
}
|
||||
|
||||
$this->save();
|
||||
$this->save(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the thread to the database
|
||||
*
|
||||
* @param boolean $update_revision Indicates if last modified time and last revision should be updated
|
||||
*/
|
||||
public function save(){
|
||||
public function save($update_revision = true){
|
||||
$db = Database::getInstance();
|
||||
|
||||
$query = "update {chatthread} t " .
|
||||
"set lrevision = ?, dtmmodified = ?";
|
||||
// Update modified time and last revision if need
|
||||
if ($update_revision) {
|
||||
$this->lastRevision = $this->nextRevision();
|
||||
$this->modified = time();
|
||||
}
|
||||
|
||||
$values = array();
|
||||
$values[] = $this->nextRevision();
|
||||
$values[] = time();
|
||||
|
||||
$set_clause = array();
|
||||
foreach ($this->updatedFields as $field_name) {
|
||||
$query .= ", {$field_name} = ?" ;
|
||||
$set_clause[] = "{$field_name} = ?";
|
||||
$values[] = $this->threadInfo[$field_name];
|
||||
}
|
||||
|
||||
$query .= " where threadid = ?";
|
||||
$query = "update {chatthread} t set " . implode(', ', $set_clause) . " where threadid = ?";
|
||||
$values[] = $this->id;
|
||||
$db->query($query, $values);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user