Peel off SQL so that others things can be selected.
This commit is contained in:
parent
9231eb9f46
commit
a6c9d3c3d1
1 changed files with 10 additions and 3 deletions
|
|
@ -439,6 +439,7 @@ sub getMessageSql {
|
||||||
my $sortDir = $props->{sortDir};
|
my $sortDir = $props->{sortDir};
|
||||||
my $whereClause = $props->{whereClause};
|
my $whereClause = $props->{whereClause};
|
||||||
my $limit = $props->{limit};
|
my $limit = $props->{limit};
|
||||||
|
my $select = $props->{'select'};
|
||||||
|
|
||||||
if($sortBy) {
|
if($sortBy) {
|
||||||
$sortBy = qq{ORDER BY $sortBy $sortDir};
|
$sortBy = qq{ORDER BY $sortBy $sortDir};
|
||||||
|
|
@ -452,6 +453,14 @@ sub getMessageSql {
|
||||||
$limit = qq{LIMIT $limit};
|
$limit = qq{LIMIT $limit};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$select) {
|
||||||
|
$select =<<SELECT;
|
||||||
|
ibox.messageId, ibox.subject, ibox.sentBy, ibox.dateStamp,
|
||||||
|
(IF(ibox.status = 'completed' or ibox.status = 'pending',ibox.status,IF(inbox_messageState.repliedTo,'replied',IF(inbox_messageState.isRead,'read','unread')))) as messageStatus,
|
||||||
|
(IF(userProfileData.firstName != '' and userProfileData.firstName is not null and userProfileData.lastName !='' and userProfileData.lastName is not null, concat(userProfileData.firstName,' ',userProfileData.lastName),users.username)) as fullName
|
||||||
|
SELECT
|
||||||
|
}
|
||||||
|
|
||||||
my $messageLimit = 20_000;
|
my $messageLimit = 20_000;
|
||||||
my $limitHalf = $messageLimit / 2;
|
my $limitHalf = $messageLimit / 2;
|
||||||
my $limitQuarter = $messageLimit / 4;
|
my $limitQuarter = $messageLimit / 4;
|
||||||
|
|
@ -461,9 +470,7 @@ sub getMessageSql {
|
||||||
# for performance purposes don't use datasets larger than 20000 no matter how man messages are in the inbox
|
# for performance purposes don't use datasets larger than 20000 no matter how man messages are in the inbox
|
||||||
my $sql = qq{
|
my $sql = qq{
|
||||||
SELECT
|
SELECT
|
||||||
ibox.messageId, ibox.subject, ibox.sentBy, ibox.dateStamp,
|
$select
|
||||||
(IF(ibox.status = 'completed' or ibox.status = 'pending',ibox.status,IF(inbox_messageState.repliedTo,'replied',IF(inbox_messageState.isRead,'read','unread')))) as messageStatus,
|
|
||||||
(IF(userProfileData.firstName != '' and userProfileData.firstName is not null and userProfileData.lastName !='' and userProfileData.lastName is not null, concat(userProfileData.firstName,' ',userProfileData.lastName),users.username)) as fullName
|
|
||||||
FROM (
|
FROM (
|
||||||
( SELECT messageId, subject, sentBy, dateStamp, status FROM inbox WHERE userId = '$userId' order by dateStamp desc limit $limitHalf)
|
( SELECT messageId, subject, sentBy, dateStamp, status FROM inbox WHERE userId = '$userId' order by dateStamp desc limit $limitHalf)
|
||||||
UNION
|
UNION
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue