mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
Исправление дублирования подписчиков/лайков/друзей (#941)
This commit is contained in:
parent
a2384cc231
commit
5c76b56da4
7 changed files with 10 additions and 7 deletions
|
@ -272,7 +272,7 @@ class Club extends RowModel
|
|||
return false;
|
||||
}
|
||||
|
||||
return $query;
|
||||
return $query->group("follower");
|
||||
}
|
||||
|
||||
function getFollowersCount(): int
|
||||
|
|
|
@ -84,7 +84,7 @@ abstract class Postable extends Attachable
|
|||
return sizeof(DB::i()->getContext()->table("likes")->where([
|
||||
"model" => static::class,
|
||||
"target" => $this->getRecord()->id,
|
||||
]));
|
||||
])->group("origin"));
|
||||
}
|
||||
|
||||
# TODO add pagination
|
||||
|
|
|
@ -39,10 +39,13 @@ class User extends RowModel
|
|||
$query = "SELECT id FROM\n" . file_get_contents(__DIR__ . "/../sql/$filename.tsql");
|
||||
$query .= "\n LIMIT " . $limit . " OFFSET " . ( ($page - 1) * $limit );
|
||||
|
||||
$ids = [];
|
||||
$rels = DatabaseConnection::i()->getConnection()->query($query, $id, $id);
|
||||
foreach($rels as $rel) {
|
||||
$rel = (new Users)->get($rel->id);
|
||||
if(!$rel) continue;
|
||||
if(in_array($rel->getId(), $ids)) continue;
|
||||
$ids[] = $rel->getId();
|
||||
|
||||
yield $rel;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(SELECT follower AS __id FROM
|
||||
(SELECT DISTINCT(follower) AS __id FROM
|
||||
(SELECT follower FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
LEFT JOIN
|
||||
(SELECT target FROM subscriptions WHERE follower=? AND model="openvk\\Web\\Models\\Entities\\User") u1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(SELECT follower AS __id FROM
|
||||
(SELECT DISTINCT(follower) AS __id FROM
|
||||
(SELECT follower FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
INNER JOIN
|
||||
(SELECT target FROM subscriptions WHERE follower=? AND model="openvk\\Web\\Models\\Entities\\User") u1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(SELECT follower AS __id FROM
|
||||
(SELECT DISTINCT(follower) AS __id FROM
|
||||
(SELECT follower FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
INNER JOIN
|
||||
(SELECT target FROM subscriptions WHERE follower=? AND model="openvk\\Web\\Models\\Entities\\User") u1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(SELECT target AS __id FROM
|
||||
(SELECT DISTINCT(target) AS __id FROM
|
||||
(SELECT follower FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
RIGHT JOIN
|
||||
(SELECT target FROM subscriptions WHERE follower=? AND model="openvk\\Web\\Models\\Entities\\User") u1
|
||||
|
|
Loading…
Reference in a new issue