rewrote pingUpdatedWeblogs() to use direct db access
This commit is contained in:
parent
b850193ea4
commit
7d4b04498b
1 changed files with 27 additions and 14 deletions
|
@ -297,23 +297,35 @@ function logAccess() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function pingUpdatedWeblogs() {
|
function pingUpdatedWeblogs() {
|
||||||
for (var i=0; i<root.allWeblogs.size(); i++) {
|
var now = new Date();
|
||||||
var blog = root.allWeblogs.get(i);
|
var period = 1000 * 60 * 60; // one hour
|
||||||
var now = new Date();
|
|
||||||
var period = 1000 * 60 * 60; // one hour
|
var c = getDBConnection("antville");
|
||||||
if ((now - blog.lastPing >= period) && (now - blog.lastUpdate <= period) && blog.online) {
|
var error = c.getLastError();
|
||||||
writeln(blog.title + " was updated, so i'll ping weblogs.com...");
|
if (error) {
|
||||||
var url = getProperty("baseURI") + blog.href();
|
writeln("Error establishing DB connection: " + error);
|
||||||
//var ping = getURL("http://newhome.weblogs.com/pingSiteForm?name=" + blog.title + "&url=" + url);
|
return;
|
||||||
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 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
|
* parse a timestamp into a date object. This is used when users
|
||||||
* want to set createtime explicitly when creating/editing stories.
|
* want to set createtime explicitly when creating/editing stories.
|
||||||
|
@ -327,6 +339,7 @@ function parseTimestamp (time, format) {
|
||||||
return df.parse (time);
|
return df.parse (time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scheduler performing auto-disposal of inactive weblogs
|
* scheduler performing auto-disposal of inactive weblogs
|
||||||
* and auto-blocking of private weblogs
|
* and auto-blocking of private weblogs
|
||||||
|
|
Loading…
Add table
Reference in a new issue