1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2026-01-30 10:47:11 +00:00

request label counters conditionally

This commit is contained in:
Andrew Dolgov
2021-02-24 15:07:31 +03:00
parent 9313ebf2e7
commit 553548b689
7 changed files with 159 additions and 70 deletions

View File

@@ -640,10 +640,41 @@ class Article extends Handler_Protected {
return [$article_image, $article_stream, $article_kind];
}
static function _feeds_of(array $article_ids) {
// 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 feed_id FROM ttrss_entries e, ttrss_user_entries ue
$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
WHERE ue.ref_id = e.id AND id IN ($id_qmarks)");
$sth->execute($article_ids);