array_push($ret_arr, $cv);
- $age_qpart = getMaxAgeSubquery();
-
$result = db_query($link, "SELECT id AS cat_id, value AS unread
FROM ttrss_feed_categories, ttrss_cat_counters_cache
WHERE ttrss_cat_counters_cache.feed_id = id AND
$cat_query = "cat_id IS NULL";
}
- $age_qpart = getMaxAgeSubquery();
-
$result = db_query($link, "SELECT id FROM ttrss_feeds WHERE $cat_query
AND owner_uid = " . $owner_uid);
$match_part = implode(" OR ", $cat_feeds);
$result = db_query($link, "SELECT COUNT(int_id) AS unread
- FROM ttrss_user_entries,ttrss_entries
- WHERE unread = true AND ($match_part) AND id = ref_id
- AND $age_qpart AND owner_uid = " . $owner_uid);
+ FROM ttrss_user_entries
+ WHERE unread = true AND ($match_part)
+ AND owner_uid = " . $owner_uid);
$unread = 0;
$result = db_query($link, "
SELECT COUNT(unread) AS unread FROM
- ttrss_user_entries, ttrss_labels2, ttrss_user_labels2, ttrss_feeds
- WHERE label_id = ttrss_labels2.id AND article_id = ref_id AND
- ttrss_labels2.owner_uid = '$owner_uid'
- AND unread = true AND feed_id = ttrss_feeds.id
+ ttrss_user_entries, ttrss_user_labels2
+ WHERE article_id = ref_id AND unread = true
AND ttrss_user_entries.owner_uid = '$owner_uid'");
$unread = db_fetch_result($result, 0, "unread");
}
}
- function getMaxAgeSubquery($days = COUNTERS_MAX_AGE) {
- if (DB_TYPE == "pgsql") {
- return "ttrss_entries.date_updated >
- NOW() - INTERVAL '$days days'";
- } else {
- return "ttrss_entries.date_updated >
- DATE_SUB(NOW(), INTERVAL $days DAY)";
- }
- }
-
function getFeedUnread($link, $feed, $is_cat = false) {
return getFeedArticles($link, $feed, $is_cat, true, $_SESSION["uid"]);
}
function getLabelUnread($link, $label_id, $owner_uid = false) {
if (!$owner_uid) $owner_uid = $_SESSION["uid"];
- $result = db_query($link, "
- SELECT COUNT(unread) AS unread FROM
- ttrss_user_entries, ttrss_labels2, ttrss_user_labels2, ttrss_feeds
- WHERE label_id = ttrss_labels2.id AND article_id = ref_id AND
- ttrss_labels2.owner_uid = '$owner_uid' AND ttrss_labels2.id = '$label_id'
- AND unread = true AND feed_id = ttrss_feeds.id
- AND ttrss_user_entries.owner_uid = '$owner_uid'");
+ $result = "SELECT COUNT(ref_id) FROM ttrss_user_entries, ttrss_user_labels2
+ WHERE owner_uid = '$owner_uid' AND unread = true AND label_id = '$label_id' AND article_id = ref_id";
if (db_num_rows($result) != 0) {
return db_fetch_result($result, 0, "unread");
$owner_uid = false) {
$n_feed = (int) $feed;
+ $need_entries = false;
if (!$owner_uid) $owner_uid = $_SESSION["uid"];
$unread_qpart = "true";
}
- $age_qpart = getMaxAgeSubquery();
-
if ($is_cat) {
return getCategoryUnread($link, $n_feed, $owner_uid);
} if ($feed != "0" && $n_feed == 0) {
$result = db_query($link, "SELECT SUM((SELECT COUNT(int_id)
FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
- AND ref_id = id AND $age_qpart
- AND $unread_qpart)) AS count FROM ttrss_tags
+ AND ref_id = id AND $unread_qpart)) AS count FROM ttrss_tags
WHERE owner_uid = $owner_uid AND tag_name = '$feed'");
return db_fetch_result($result, 0, "count");
} else {
$match_part .= " AND updated > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
}
+
+ $need_entries = true;
+
} else if ($n_feed == -4) {
$match_part = "true";
} else if ($n_feed >= 0) {
if ($match_part) {
- if ($n_feed != 0) {
- $from_qpart = "ttrss_user_entries,ttrss_feeds,ttrss_entries";
- $feeds_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND";
- } else {
+ if ($need_entries) {
$from_qpart = "ttrss_user_entries,ttrss_entries";
- $feeds_qpart = '';
+ $from_where = "ttrss_entries.id = ttrss_user_entries.ref_id AND";
+ } else {
+ $from_qpart = "ttrss_user_entries";
}
$query = "SELECT count(int_id) AS unread
FROM $from_qpart WHERE
- ttrss_user_entries.ref_id = ttrss_entries.id AND
- $age_qpart AND
- $feeds_qpart
- $unread_qpart AND ($match_part) AND ttrss_user_entries.owner_uid = $owner_uid";
+ $unread_qpart AND $from_where ($match_part) AND ttrss_user_entries.owner_uid = $owner_uid";
+
+ //echo "[$feed/$query]\n";
$result = db_query($link, $query);
$result = db_query($link, "SELECT COUNT(post_int_id) AS unread
FROM ttrss_tags,ttrss_user_entries,ttrss_entries
WHERE tag_name = '$feed' AND post_int_id = int_id AND ref_id = ttrss_entries.id
- AND $unread_qpart AND $age_qpart AND
- ttrss_tags.owner_uid = " . $owner_uid);
+ AND $unread_qpart AND ttrss_tags.owner_uid = " . $owner_uid);
}
$unread = db_fetch_result($result, 0, "unread");
$ret_arr = array();
- $age_qpart = getMaxAgeSubquery();
-
$result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id)
FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
- AND ref_id = id AND $age_qpart
- AND unread = true)) AS count FROM ttrss_tags
+ AND ref_id = id AND unread = true)) AS count FROM ttrss_tags
WHERE owner_uid = ".$_SESSION['uid']." GROUP BY tag_name
ORDER BY count DESC LIMIT 55");
$ret_arr = array();
- $age_qpart = getMaxAgeSubquery();
-
$owner_uid = $_SESSION["uid"];
$result = db_query($link, "SELECT id, caption FROM ttrss_labels2
$ret_arr = array();
- $age_qpart = getMaxAgeSubquery();
-
$query = "SELECT ttrss_feeds.id,
ttrss_feeds.title,
".SUBSTRING_FOR_DATE."(ttrss_feeds.last_updated,1,19) AS last_updated,
-<?php # This file has been generated at: Thu Jan 12 12:16:17 MSK 2012
+<?php # This file has been generated at: Mon Jul 9 12:33:19 MSK 2012
define('GENERATED_CONFIG_CHECK', 25);
-$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'DEFAULT_UPDATE_METHOD', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'AUTO_CREATE_USER', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_HOST', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'CHECK_FOR_NEW_VERSION', 'COUNTERS_MAX_AGE', 'ENABLE_GZIP_OUTPUT', 'FEEDBACK_URL', 'ARTICLE_BUTTON_PLUGINS', 'CONFIG_VERSION'); ?>
+$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'DEFAULT_UPDATE_METHOD', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'AUTO_CREATE_USER', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_HOST', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'CHECK_FOR_NEW_VERSION', 'ENABLE_GZIP_OUTPUT', 'FEEDBACK_URL', 'ARTICLE_BUTTON_PLUGINS', 'CONFIG_VERSION'); ?>