if ($subop == "download") {
$stage = (int) $_REQUEST["stage"];
- $cid = db_escape_string($_REQUEST["cid"]);
+ $cidt = db_escape_string($_REQUEST["cidt"]);
+ $cidb = db_escape_string($_REQUEST["cidb"]);
//$amount = (int) $_REQUEST["amount"];
//$unread_only = db_escape_string($_REQUEST["unread_only"]);
//if (!$amount) $amount = 50;
- $amount = 200;
+ $amount = 100;
$unread_only = true;
print "<rpc-reply>";
$unread_qpart = "unread = true AND ";
}
- if ($cid) {
- $cid_qpart = "id > $cid AND ";
+ if ($cidt && $cidb) {
+ $cid_qpart = "(id > $cidt OR id < $cidb) AND ";
}
+ if (DB_TYPE == "pgsql") {
+ $date_qpart = "updated >= NOW() - INTERVAL '1 month' AND";
+ } else {
+ $date_qpart = "updated >= DATE_SUB(NOW(), INTERVAL 1 MONTH) AND";
+ }
+
$result = db_query($link,
"SELECT DISTINCT id,title,guid,link,
feed_id,content,updated,unread,marked FROM
ttrss_user_entries,ttrss_entries
- WHERE $unread_qpart $cid_qpart
+ WHERE $unread_qpart $cid_qpart $date_qpart
ref_id = id AND owner_uid = ".$_SESSION["uid"]."
ORDER BY updated DESC LIMIT $limit OFFSET $skip");
var localServer = false;
var db = false;
var download_progress_last = 0;
-var offline_dl_max_id = 0;
function activeFeedIsCat() {
return _active_feed_is_cat;
[id, title, has_icon]);
}
- window.setTimeout("update_offline_data("+(stage+1)+")", 30*1000);
+ window.setTimeout("update_offline_data("+(stage+1)+")", 60*1000);
} else {
var articles = transport.responseXML.getElementsByTagName("article");
window.setTimeout("update_offline_data("+(stage+1)+")", 60*1000);
} else {
window.setTimeout("update_offline_data(0)", 1800*1000);
+
+ var date = new Date();
+ var ts = Math.round(date.getTime() / 1000);
+
+ db.execute("DELETE FROM articles WHERE added < ? - 2592000", [ts]);
+
}
}
var query = "backend.php?op=rpc&subop=download&stage=" + stage;
- if (stage == 0) {
- var rs = db.execute("SELECT MAX(id) FROM articles");
- if (rs.isValidRow() && rs.field(0)) {
- offline_dl_max_id = rs.field(0);
- }
- }
+ var rs = db.execute("SELECT MAX(id), MIN(id) FROM articles");
+ if (rs.isValidRow() && rs.field(0)) {
+ var offline_dl_max_id = rs.field(0);
+ var offline_dl_min_id = rs.field(1);
- if (offline_dl_max_id) {
- query = query + "&cid=" + offline_dl_max_id;
+ query = query + "&cidt=" + offline_dl_max_id;
+ query = query + "&cidb=" + offline_dl_min_id;
}
new Ajax.Request(query, {