rewrote pingUpdatedWeblogs() to use direct db access

This commit is contained in:
Tobi Schäfer 2002-04-29 11:01:23 +00:00
parent b850193ea4
commit 7d4b04498b

View file

@ -297,23 +297,35 @@ function logAccess() {
*/
function pingUpdatedWeblogs() {
for (var i=0; i<root.allWeblogs.size(); i++) {
var blog = root.allWeblogs.get(i);
var now = new Date();
var period = 1000 * 60 * 60; // one hour
if ((now - blog.lastPing >= period) && (now - blog.lastUpdate <= period) && blog.online) {
writeln(blog.title + " was updated, so i'll ping weblogs.com...");
var url = getProperty("baseURI") + blog.href();
//var ping = getURL("http://newhome.weblogs.com/pingSiteForm?name=" + blog.title + "&url=" + url);
var xr = new Remote("http://rpc.weblogs.com/RPC2");
var ping = xr.weblogUpdates.ping(blog.title, url);
if (ping.error)
writeln(ping.error);
blog.lastPing = now;
var c = getDBConnection("antville");
var error = c.getLastError();
if (error) {
writeln("Error establishing DB connection: " + error);
return;
}
var query = "select ID from WEBLOG where ISONLINE = 1 and ENABLEPING = 1 and LASTUPDATE > LASTPING;";
c.executeCommand(query);
var error = c.getLastError();
if (error) {
writeln("Error executing SQL query: " + error);
return;
}
while (rows.next()) {
var id = rows.getColumnItem("ID");
var blog = root.get(id);
blog.ping();
}
rows.release();
return;
}
/**
* parse a timestamp into a date object. This is used when users
* want to set createtime explicitly when creating/editing stories.
@ -327,6 +339,7 @@ function parseTimestamp (time, format) {
return df.parse (time);
}
/**
* scheduler performing auto-disposal of inactive weblogs
* and auto-blocking of private weblogs