fix group by item query
This commit is contained in:
parent
6ea32a8ba3
commit
155b57c2de
@ -3773,7 +3773,7 @@ function zot_feed($uid,$observer_hash,$arr) {
|
|||||||
if(! is_sys_channel($uid))
|
if(! is_sys_channel($uid))
|
||||||
$sql_extra = item_permissions_sql($uid,$observer_hash);
|
$sql_extra = item_permissions_sql($uid,$observer_hash);
|
||||||
|
|
||||||
$limit = " LIMIT 100 ";
|
$limit = " LIMIT 5000 ";
|
||||||
|
|
||||||
if($mindate > NULL_DATE) {
|
if($mindate > NULL_DATE) {
|
||||||
$sql_extra .= " and ( created > '$mindate' or changed > '$mindate' ) ";
|
$sql_extra .= " and ( created > '$mindate' or changed > '$mindate' ) ";
|
||||||
@ -3785,15 +3785,7 @@ function zot_feed($uid,$observer_hash,$arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$items = array();
|
$items = [];
|
||||||
|
|
||||||
/** @FIXME re-unite these SQL statements. There is no need for them to be separate. The mySQL is convoluted with misuse of group by. As it stands, there is a slight difference where the postgres version doesn't remove the duplicate parents up to 100. In practice this doesn't matter. It could be made to match behavior by adding "distinct on (parent) " to the front of the selection list, at a not-worth-it performance penalty (page temp results to disk). duplicates are still ignored in the in() clause, you just get less than 100 parents if there are many children. */
|
|
||||||
|
|
||||||
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
|
|
||||||
$groupby = '';
|
|
||||||
} else {
|
|
||||||
$groupby = 'GROUP BY parent';
|
|
||||||
}
|
|
||||||
|
|
||||||
$item_normal = item_normal();
|
$item_normal = item_normal();
|
||||||
|
|
||||||
@ -3802,7 +3794,7 @@ function zot_feed($uid,$observer_hash,$arr) {
|
|||||||
WHERE uid != %d
|
WHERE uid != %d
|
||||||
$item_normal
|
$item_normal
|
||||||
AND item_wall = 1
|
AND item_wall = 1
|
||||||
and item_private = 0 $sql_extra $groupby ORDER BY created ASC $limit",
|
and item_private = 0 $sql_extra ORDER BY created ASC $limit",
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3810,19 +3802,25 @@ function zot_feed($uid,$observer_hash,$arr) {
|
|||||||
$r = q("SELECT parent, created, postopts from item
|
$r = q("SELECT parent, created, postopts from item
|
||||||
WHERE uid = %d $item_normal
|
WHERE uid = %d $item_normal
|
||||||
AND item_wall = 1
|
AND item_wall = 1
|
||||||
$sql_extra $groupby ORDER BY created ASC $limit",
|
$sql_extra ORDER BY created ASC $limit",
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$parents = [];
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
for($x = 0; $x < count($r); $x ++) {
|
foreach($r as $rv) {
|
||||||
if(strpos($r[$x]['postopts'],'nodeliver') !== false) {
|
if(array_key_exists($rv['parent'],$parents))
|
||||||
unset($r[$x]);
|
continue;
|
||||||
}
|
if(strpos($rv['postopts'],'nodeliver') !== false)
|
||||||
|
continue;
|
||||||
|
$parents[$rv['parent']] = $rv;
|
||||||
|
if(count($parents) > 200)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parents_str = ids_to_querystr($r,'parent');
|
$parents_str = ids_to_querystr($parents,'parent');
|
||||||
$sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
|
$sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
|
||||||
$item_normal = item_normal();
|
$item_normal = item_normal();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user