Fix multiple queries for document/comment vote count

This commit is contained in:
Kijin Sung 2016-04-24 19:50:22 +09:00
parent 4f821bca85
commit c227d188a7
6 changed files with 62 additions and 12 deletions

View file

@ -1227,7 +1227,7 @@ class commentController extends comment
// invalid vote if both ip addresses between author's and the current user are same.
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
{
$_SESSION['voted_comment'][$comment_srl] = TRUE;
$_SESSION['voted_comment'][$comment_srl] = false;
return new Object(-1, $failed_voted);
}
@ -1241,7 +1241,7 @@ class commentController extends comment
// session registered if the author information matches to the current logged-in user's.
if($member_srl && $member_srl == $oComment->get('member_srl'))
{
$_SESSION['voted_comment'][$comment_srl] = TRUE;
$_SESSION['voted_comment'][$comment_srl] = false;
return new Object(-1, $failed_voted);
}
}
@ -1264,7 +1264,7 @@ class commentController extends comment
// session registered if log info contains recommendation vote log.
if($output->data->count)
{
$_SESSION['voted_comment'][$comment_srl] = TRUE;
$_SESSION['voted_comment'][$comment_srl] = false;
return new Object(-1, $failed_voted);
}

View file

@ -284,12 +284,13 @@ class commentItem extends Object
function getVote()
{
if(!$this->comment_srl) return false;
if($_SESSION['voted_comment'][$this->comment_srl])
if(isset($_SESSION['voted_comment'][$this->comment_srl]))
{
return $_SESSION['voted_comment'][$this->comment_srl];
}
$logged_info = Context::get('logged_info');
if(!$logged_info->member_srl) return false;
$args = new stdClass();
$args->member_srl = $logged_info->member_srl;
@ -298,10 +299,10 @@ class commentItem extends Object
if($output->data->point)
{
return $output->data->point;
return $_SESSION['voted_comment'][$this->comment_srl] = $output->data->point;
}
return false;
return $_SESSION['voted_comment'][$this->comment_srl] = false;
}
/**

View file

@ -0,0 +1,13 @@
<query id="getCommentVotedLog" action="select">
<tables>
<table name="comment_voted_log" />
</tables>
<columns>
<column name="comment_srl" />
<column name="point" />
</columns>
<conditions>
<condition operation="in" column="comment_srl" var="comment_srls" filter="number" notnull="notnull" />
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
</conditions>
</query>