mirror of
				https://github.com/Mibew/java.git
				synced 2025-11-04 12:25:12 +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();
 | 
							$thread = Thread::create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Update thread values
 | 
							// Update thread values
 | 
				
			||||||
		$thread->lastRevision = $last_revision = 10;
 | 
					 | 
				
			||||||
		$thread->state = $state = Thread::STATE_CHATTING;
 | 
							$thread->state = $state = Thread::STATE_CHATTING;
 | 
				
			||||||
		$thread->lastToken = $last_token = 11;
 | 
							$thread->lastToken = $last_token = 11;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -309,7 +308,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
 | 
				
			|||||||
		$thread->messageCount = $message_count = 15;
 | 
							$thread->messageCount = $message_count = 15;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$thread->created = $created = time() - 200;
 | 
							$thread->created = $created = time() - 200;
 | 
				
			||||||
		$thread->modified = $modified = time() - 190;
 | 
					 | 
				
			||||||
		$thread->chatStarted = $chat_started = time() - 180;
 | 
							$thread->chatStarted = $chat_started = time() - 180;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$thread->agentId = $agent_id = 16;
 | 
							$thread->agentId = $agent_id = 16;
 | 
				
			||||||
@ -336,7 +334,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase {
 | 
				
			|||||||
		$thread_info = $this->_helper_getThreadInfo($thread->id);
 | 
							$thread_info = $this->_helper_getThreadInfo($thread->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Check values
 | 
							// Check values
 | 
				
			||||||
		$this->assertEquals($thread_info['lrevision'],$last_revision);
 | 
					 | 
				
			||||||
		$this->assertEquals($thread_info['istate'], $state);
 | 
							$this->assertEquals($thread_info['istate'], $state);
 | 
				
			||||||
		$this->assertEquals($thread_info['ltoken'], $last_token);
 | 
							$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['messageCount'], $message_count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->assertEquals($thread_info['dtmcreated'], $created);
 | 
							$this->assertEquals($thread_info['dtmcreated'], $created);
 | 
				
			||||||
		$this->assertEquals($thread_info['dtmmodified'], $modified);
 | 
					 | 
				
			||||||
		$this->assertEquals($thread_info['dtmchatstarted'], $chat_started);
 | 
							$this->assertEquals($thread_info['dtmchatstarted'], $chat_started);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->assertEquals($thread_info['agentId'], $agent_id);
 | 
							$this->assertEquals($thread_info['agentId'], $agent_id);
 | 
				
			||||||
 | 
				
			|||||||
@ -526,28 +526,31 @@ Class Thread {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->save();
 | 
							$this->save(false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Save the thread to the database
 | 
						 * 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();
 | 
							$db = Database::getInstance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$query = "update {chatthread} t " .
 | 
							// Update modified time and last revision if need
 | 
				
			||||||
			"set lrevision = ?, dtmmodified = ?";
 | 
							if ($update_revision) {
 | 
				
			||||||
 | 
								$this->lastRevision = $this->nextRevision();
 | 
				
			||||||
 | 
								$this->modified = time();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$values = array();
 | 
							$values = array();
 | 
				
			||||||
		$values[] = $this->nextRevision();
 | 
							$set_clause = array();
 | 
				
			||||||
		$values[] = time();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		foreach ($this->updatedFields as $field_name) {
 | 
							foreach ($this->updatedFields as $field_name) {
 | 
				
			||||||
			$query .= ", {$field_name} = ?" ;
 | 
								$set_clause[] = "{$field_name} = ?";
 | 
				
			||||||
			$values[] = $this->threadInfo[$field_name];
 | 
								$values[] = $this->threadInfo[$field_name];
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$query .= " where threadid = ?";
 | 
							$query = "update {chatthread} t set " . implode(', ', $set_clause) . " where threadid = ?";
 | 
				
			||||||
		$values[] = $this->id;
 | 
							$values[] = $this->id;
 | 
				
			||||||
		$db->query($query, $values);
 | 
							$db->query($query, $values);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user