offline: schema fixes

This commit is contained in:
Andrew Dolgov 2009-02-07 10:22:15 +03:00
parent 5b88081798
commit 711f946160
1 changed files with 5 additions and 6 deletions

View File

@ -1,4 +1,4 @@
var SCHEMA_VERSION = 9; var SCHEMA_VERSION = 10;
var offline_mode = false; var offline_mode = false;
var store = false; var store = false;
@ -698,10 +698,8 @@ function offline_download_parse(stage, transport) {
window.setTimeout("update_offline_data(0)", 1800*1000); window.setTimeout("update_offline_data(0)", 1800*1000);
debug("update_offline_data: finished"); debug("update_offline_data: finished");
var date = new Date(); db.execute("DELETE FROM articles WHERE "+
var ts = Math.round(date.getTime() / 1000); "updated < DATETIME('NOW', 'localtime', '-31 days')");
db.execute("DELETE FROM articles WHERE added < ? - 2592000", [ts]);
} }
} }
@ -952,7 +950,8 @@ function init_gears() {
db.execute("CREATE TRIGGER IF NOT EXISTS articles_update_modified "+ db.execute("CREATE TRIGGER IF NOT EXISTS articles_update_modified "+
"UPDATE OF unread ON articles "+ "UPDATE OF unread ON articles "+
"BEGIN "+ "BEGIN "+
"UPDATE articles SET modified = DATETIME('NOW') WHERE id = old.id AND "+ "UPDATE articles SET modified = DATETIME('NOW', 'localtime') "+
"WHERE id = old.id AND "+
"old.unread = 1;"+ "old.unread = 1;"+
"END;"); "END;");