diff options
author | Andrew Dolgov <[email protected]> | 2021-02-24 15:07:31 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-24 15:07:31 +0300 |
commit | 553548b6897f8ef292ab56af9dcc196ef8ee0cb3 (patch) | |
tree | feae3a51d884e216d4d460634024ef7884227b14 /classes/article.php | |
parent | 9313ebf2e745731263a8e24d19473adb70dfee47 (diff) |
request label counters conditionally
Diffstat (limited to 'classes/article.php')
-rwxr-xr-x | classes/article.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/classes/article.php b/classes/article.php index f77275122..6baf8f068 100755 --- a/classes/article.php +++ b/classes/article.php @@ -640,10 +640,41 @@ class Article extends Handler_Protected { return [$article_image, $article_stream, $article_kind]; } + // only cached, returns label ids (not label feed ids) + static function _labels_of(array $article_ids) { + if (count($article_ids) == 0) + return []; + + $id_qmarks = arr_qmarks($article_ids); + + $sth = Db::pdo()->prepare("SELECT DISTINCT label_cache FROM ttrss_entries e, ttrss_user_entries ue + WHERE ue.ref_id = e.id AND id IN ($id_qmarks)"); + + $sth->execute($article_ids); + + $rv = []; + + while ($row = $sth->fetch()) { + $labels = json_decode($row["label_cache"]); + + if (isset($labels) && is_array($labels)) { + foreach ($labels as $label) { + if (empty($label["no-labels"])) + array_push($rv, Labels::feed_to_label_id($label[0])); + } + } + } + + return array_unique($rv); + } + static function _feeds_of(array $article_ids) { + if (count($article_ids) == 0) + return []; + $id_qmarks = arr_qmarks($article_ids); - $sth = DB::pdo()->prepare("SELECT DISTINCT feed_id FROM ttrss_entries e, ttrss_user_entries ue + $sth = Db::pdo()->prepare("SELECT DISTINCT feed_id FROM ttrss_entries e, ttrss_user_entries ue WHERE ue.ref_id = e.id AND id IN ($id_qmarks)"); $sth->execute($article_ids); |