mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
add fast sql statement to getReceiptStatus() if limit=1
This commit is contained in:
parent
f3e1c56d5d
commit
39b94d4c75
|
@ -3824,9 +3824,27 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
|
||||
// Retrieve the current status of each assigned reviewer for the content
|
||||
// represented by this object.
|
||||
// When just the last log entry for each recipient is needed then a single
|
||||
// sql statement is much faster than the code below which first retrieves
|
||||
// all receivers and than the logs
|
||||
// FIXME: caching was turned off to make list of review log in ViewDocument
|
||||
// possible
|
||||
if (1 || !isset($this->_receiptStatus)) {
|
||||
if($limit == 1) {
|
||||
/* The following sql statement is somewhat optimized. The first join is
|
||||
* crucial because it should first take the table with the least number
|
||||
* of records and join the other tables. ttreceiptid join tblDocumentRecipients
|
||||
* is faster than tblDocumentRecipients join ttreceiptid
|
||||
*/
|
||||
$queryStr=
|
||||
"SELECT `tblDocumentRecipients`.*, `tblDocumentReceiptLog`.`receiptLogID`, `tblDocumentReceiptLog`.`status`, `tblDocumentReceiptLog`.`comment`, `tblDocumentReceiptLog`.`date`, `tblDocumentReceiptLog`.`userID`, `tblUsers`.`fullName`, `tblGroups`.`name` FROM `ttreceiptid` LEFT JOIN `tblDocumentRecipients` ON `tblDocumentRecipients`.`receiptID`=`ttreceiptid`.`receiptID` LEFT JOIN `tblDocumentReceiptLog` ON `ttreceiptid`.`maxLogID`=`tblDocumentReceiptLog`.`receiptLogID` LEFT JOIN `tblUsers` ON `tblDocumentRecipients`.`required`=`tblUsers`.`id` LEFT JOIN `tblGroups` ON `tblDocumentRecipients`.`required`=`tblGroups`.`id` WHERE `version`='".$this->_version
|
||||
."' AND `documentID` = '". $this->_document->getID() ."' ";
|
||||
$recs = $db->getResultArray($queryStr);
|
||||
if (is_bool($recs) && !$recs) {
|
||||
unset($this->_receiptStatus);
|
||||
return false;
|
||||
}
|
||||
$this->_receiptStatus = $recs;
|
||||
} elseif (1 || !isset($this->_receiptStatus)) {
|
||||
/* First get a list of all receipts for this document content */
|
||||
$queryStr=
|
||||
"SELECT `receiptID` FROM `tblDocumentRecipients` WHERE `version`='".$this->_version
|
||||
|
|
Loading…
Reference in New Issue
Block a user